Why we put the datas in private | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we put the datas in private

14th Feb 2018, 12:50 PM
Vibeeshanan Vibee
Vibeeshanan Vibee - avatar
2 Answers
+ 2
So other things can't access it
14th Feb 2018, 1:06 PM
Vlad Serbu
Vlad Serbu - avatar
+ 1
The code becomes safer (and easier to understand and reuse) when we use the private keyword for variables and methods that should be accessible only within the declared class itself.
14th Feb 2018, 2:31 PM
Aleksandr