Java is a 100% POO language, so to starts a Java software, our main function need to be a class method.
The filename need to be the same of the class that was declared in this file.
So the basic structure of Java file is:
class Program {
public static void main(String[] args) {
System.out.println("Hello World");
}
}Where Program is the class name of this file and main the method name, i.e., the main function that will be executed.
publicmeans that ourmain()method can be used by all files that importsProgramstaticmeans that ourmain()method can be called without instantiate the classProgramvoidmeans that ourmain()method doesn't return anythingargsis the argument that ourmain()method receives. In this case, an array ofStringobjects. This is the way that Java receives the arguments passed by the command line.System.out.println()is the way that Java print something in the console.Systemis a class that Java provides to us native methods to interact with the systemoutis a static object ofSystemclass that represents the output streamprintln()is a method ofoutobject that prints a string and a new line (Alternative:print(), that prints only the string without a new line)
And, the filename need to be Program.java because our class is named Program.