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, 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:

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:

Java Program Syntax Output

In this lesson, we learned about Java syntax and what is public static void main.

Run Java First Program on Windows 10
Operators in Java
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

1 Comment
  • Jereld James Camphor
    Posted at 19:47h, 08 May Reply

    I am impressed. But there is a lot of stuff to digest.

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading