What is the difference between private and protected specifiers ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between private and protected specifiers ?

Needs explaination with their properties.....thanks

20th Aug 2017, 5:39 PM
Hemant Jaiswal
Hemant Jaiswal - avatar
1 Answer
+ 2
`private` hides from other classes within the package. `public` exposes to classes outside the package. `protected` is a version of `public` restricted only to subclasses. you may find detailed docs here http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
20th Aug 2017, 6:24 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar