What is the difference between access modifier private and access modifier public | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

What is the difference between access modifier private and access modifier public

24th Mar 2019, 12:41 PM
alvin
alvin - avatar
2 Réponses
+ 7
If you declare any variable with public modifier, then *all* methods (functions) will be able to access that variable's value. But if you declare any variable with private modifier, then only the methods (functions) of the same class can access that variable's value.
24th Mar 2019, 12:45 PM
Letsintegreat
Letsintegreat - avatar
24th Mar 2019, 12:50 PM
Scooby
Scooby - avatar