+ 1

Why we have access modifier ? What are the uses of having public,privite keywords

1st Mar 2019, 9:54 AM
Hakash
Hakash - avatar
2 ответов
+ 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
1st Mar 2019, 10:12 AM
Ilya R
Ilya R - avatar
+ 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.
3rd Mar 2019, 12:39 PM
M_N