24 Aug Java Syntax
Here, we will learn how to understand first program in java. What all is included in a Java program will be discussed i.e. Java syntax.
Learn how to setup Java and run your Java program before beginning with understanding the first Java program.
Create a new file StudyopediaDemo and save it as StudyopediaDemo.java, since java program has .java extension. The name of the file should match the class name, So, the class name in our program is StudyopediaDemo:
public static void main(String arg)
System.out.println("Here's our first program!");
System.out.println("Studyopedia.com - Never Stop Learning");
Here’s about the Java Syntax, including the public static void main,
- class: To define a new class
- public: This is access specifier.
- static: It allows main( ) to be called without the need to instantiate a particular instance.
- void: return type
- main: It is called when Java application begins
- String arg: This declares a parameter arg, which is an array of instances of the class String. The array args is to receive any command-line arguments.
- System: Predefined class that provides access
- out: The output stream
- println: To display the string
Run the above program and you can see the following output:
In this lesson, we learned about Java syntax and what is public static void main.