What is the point of private and public methods?


What is the point of private and public methods?

-when used
just to get a clear understanding of private and public methods.


Hey @codesmax! Methods that are private can only be called by methods within the same class, so other classes cant change the method. In a Javascript/Java game programming this is most likely used, but in other type of programmings its not as common. And public methods are methods than can be called by other classes! Normally private methods this is not used in javascript(Again im not sure), but most oftenly used in Java game development! Hope this helped!


Public methods are intended for use outside the class, and private methods are for internal use. One of the benefits of object-oriented programming is that programmers do not need to know the details about how the class was programed in order to use it. However, as a result, programmers may inadvertently interfere with the class; to prevent interference, class members which are meant to be used by programmers utilizing the class are made public, and other members are made private.

EDIT: Whoops, I thought I was in the Java forum... I know that my answer is correct for Java, but I've heard that JavaScript's OOP is different, and doesn't have classes. Never mind.


thank you


@chibi_matoran Dont worry chibi, its always great to get an insight on different languages, i am 13 and highly talented in school and find it boring right now so for a self challenge i tried to put myself on a path where i would be able to create a game for my android device or even a website but mostly a game on my android, you sound quite advanced in programming am i right? Can you tell me what language i should learn for game development and what Apps i have to download to be able to write games (for example i have finished the javascript course but i have no idea where i can write that code,'What app should i download?')and i am planing on learning Java, Html and CSS, what do you think of that choice? what about Python? sorry to ask you all these questions but there are so many videos on youtube,tutorials but i get confused with them all

-Merry Christmas-


I'm not advanced; I'm a beginner. However, I know that Android apps can be written in Java and iOS apps can be written in Objective-C or Swift.