What is the difference when we define a class in public and when we define it simply without writing public ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference when we define a class in public and when we define it simply without writing public ?

For ex :- "public class one " and "class two"

21st Jun 2017, 10:26 AM
Vishal
Vishal - avatar
1 Answer
+ 14
Unless it's public, the class won't be visible to other code which isn't in the same package. The default accessibility (which can't be specified explicitly) is that a class (or other member) is only visible to other code within the same package.
21st Jun 2017, 10:51 AM
Dev
Dev - avatar