Because this first section of code may appear confusing, we will take it line by line.
This line is simply explaining the file structure of the location of the code you are looking at right now. From your main Eclipse directory, you will go to the project name, to com, to folder, and lastly folderexample. Finally, your class will be in a Java file in this folder. Your code may be in “C:\Users\workspace\projectexample\com\folder\folderexample\MyClass.Java.” Notice that package is lowercase.
Public is a keyword that declares a member’s class. Public means that any other class can access this information. Other classes can modify this class UNLESS it is declared final. Classes may also be protected, meaning only other classes within the same package can access this class. Finally, private classes cannot be accessed outside of itself. This means methods can only be accessed within their class. Notice that public is lowercase.
Class, obviously, is to define a class. Lastly, your class name. Your class is contained within curly brackets ({ and }).
public is defining the method’s access, just as it did for the class. This method is public, and therefore can be seen and used in other classes. Notice that public is lowercase.
The word static means that the method is available at class level. In other words, you don’t need to create an object to call the method. You can simply use the entire class. These are used for main methods, as well.
void is defining what the method returns. This method does not return anything. For example, if a method were to return a string instead of nothing, it may say “public string methodName().”
Within a method’s parentheses are the parameters that can be passed to your method. In a main method, the parameter passed is an array of Strings that is declared as “args.” This allows you to pass arguments (strings) to your main method.