+ 1
Why we have access modifier ? What are the uses of having public,privite keywords
2 Antworten
+ 8
You need them to limit the data for some classes or make them public .For example, protected gives data only to the extend class ,public gives all data , private doesn't give us data.
https://code.sololearn.com/c6x7dgH4PD1S/?ref=app
+ 1
You have different classes with its own methods. One method you can call outside the class - it will be public. Other method you will use just inside the class - private. Just think about modifier like "for all"/"for me/etc.