![]() ![]() Java's public access modifier is the least protective of the modifiers, and should be used only when you absolutely know that you want anything and everything to be allowed access to the methods and variables. This means if you have a MathUtil object in any other class, you can use its public methods and variables: These routines and variables can be accessed from anywhere. Here's an example of a MathUtil class that has common math routines and variables. Usually common routines and variables that need to be shared everywhere are declared public. ![]() This is useful for when the variable should be accessible by your entire application. A variable or method that is public means that any class can access it. Public is also the easiest of the Java access modifiers because of its nature. Public is the most well known of the Java keywords. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |