-2

Meaning if I ommit the access modifier for members of local classes, can the class declaring method access the members? And who else exactly?

I'm talking about local classes, that are classes defined inside a method

THEREFORE THIS IS NOT A DUPLICATE

user777
  • 886
  • 5
  • 16
  • 1
    have a look at http://www.javatpoint.com/access-modifiers – Vihar Apr 23 '15 at 09:50
  • 1
    possible duplicate of [In Java, what's the difference between public, default, protected, and private?](http://stackoverflow.com/questions/215497/in-java-whats-the-difference-between-public-default-protected-and-private) – Vogel612 Apr 23 '15 at 09:53
  • 1
    possible duplicate of [What is the default access modifier in java?](http://stackoverflow.com/questions/16164902/what-is-the-default-access-modifier-in-java) – Raedwald Apr 23 '15 at 19:45

2 Answers2

1

The default modifier is package level modifier. Accessable inside the package.

Veselin Davidov
  • 6,886
  • 1
  • 13
  • 21
  • Your are mixing [inner classes](https://docs.oracle.com/javase/tutorial/java/javaOO/innerclasses.html) with [local classes](https://docs.oracle.com/javase/tutorial/java/javaOO/localclasses.html). – SubOptimal Apr 23 '15 at 10:24
1

Local classes cannot be declared public, protected, private, or static. These modifiers are for members of classes; they are not allowed with local variable declarations or local class declarations.

*Meaning if I ommit the access modifier for members of local classes, can the class declaring method access the members?*

No the class declaring the method cannot access the local class members. A local class is visible only within the block that defines it; it can never be used outside that block.

underdog
  • 4,188
  • 7
  • 38
  • 81
  • I'm not talking about the class declaring **the** method, but the class-declaring-method, the method that declares the inner local class. – user777 Apr 23 '15 at 11:28