KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why can't we have static method in a non-static inner class? public class Foo { class Bar { static void method() {} // Compiler error } } If I make the inner class static it works. Why? public class Foo { static class Bar { // now static static void method() {} } } In Java 16+, both of these are valid.
Tags (comma-separated)
Save Edits
Cancel