Doubts about top level class acess modifiers in Java -


i have doubts access modifiers used top level classes in java.

1) can access modifier public or default used top level classes or nested classes?

2) lets there 2 different classes , b, both in different packages. in order have access (acess class members) class class b , both top level class, ‘a’ class members should defined public, right ? if either class or class members not public class b not have access class a, right ?

please correct if i'm wrong.

1) nested classes can have same access modifiers top level classes.

2) in order access class class b, needs public. class b may package private (default). b can access methods of if a's methods public (if b not inherit a). if class package private, doesn't matter if contains public methods - won't accessible b.

see oracle docs , this stackoverflow thread.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -