JAVA Tutorial I – Explanation of the Code
There are 3 major sections of this code. The Header, Main Function, and Output. We’ll look over all three of them for a better understanding of the code.
Header
The Header was the part at the beginning of all of the code.
public class HelloWorld { |
For all of your JAVA programs, this part is already added at the beginning. “public class” means that the program can be accessed anywhere (doesn’t make a lot of sense, but is necessary.) In this piece of code, the “HelloWorld” happens to also be the name of the class we made.
Main Function
Main Function is a bit of code almost all of the programming languages used and is put at the beginning of it all. If you are familiar with C++, the Main Function is int main (). The Main Function in JAVA is the following:
public static void main(String[] args) { |
It is a bit hard to translate this into an English term and define all the sections. One must understand that this is one of the most crucial parts of the entire JAVA program, and any other program you plan to write in JAVA.
Output
This is the part that made the text “Hello World!” appear in your Console.
System.out.print(“Hello World!”); |
As we dissect this little piece of code into mini sections, you will notice that the text in between the quotations is what was displayed in the console. You’re absolutely correct. You can change the text within the quotes and it’ll make the text in the console different.
Here are the Translations for the remaining 3 parts:
- The word “print” makes the text “Hello World!” appear.
- System is required to make the rest of the text work successfully (it’s kind of required for all of the output text)
- Out means, well, output text
CONGRATULATIONS! You successfully mastered the Hello World! for JAVA! That’s another one for your arsenal of Hello Worlds! I appreciate your time!
<<Previous Page – If you Want to Refer to Anything Else
Leave a Comment