Syntax of Java

Syntax means set of  rules that define the structure of any language and it tells the computers how to read code. Syntax in any computer programming languages like C, C++, Java etc means the rules that control the structure of the symbols, punctuations, and words of a computer programming language.

Each computer programming languages have their own syntax and words for syntax and we have to write the code according to their syntax otherwise we will get error if we do not follow the syntax of particular language.

Suppose that we write the code for any program and that code does not match with the syntax of any programming then is will not be understood by compiler and when compiler will not understand the code then it will not convert it into binary code or machine language that computer can understand so finally we will get an error as a result. 

Interpreters are used to check the code line by line and it is used to execute computer programming  languages such as JavaScript or Python at runtime. The incorrect syntax will cause the code to fail.

Therefore to become a good programmer you should pay close attention to syntax of programming languages so that you can run any kind of programs successfully.

Syntax of Java language is given below

class Easy
 public static void main(String[] args) 
   System.out.println("Hello World");       

class1.It is a keyword which is used to declare a class.
2.Keyword:The word which is predefined in the library is called keyword. for example class, void ,main etc.
Easy1.It is an user-defined class name.
public1.It is a keyword which is called access specifier/modifier.
2.It is used to provide accessibility of data member(variable) and member function(function).
static1.It is a keyword.
2.It can be used with a variable or function or block, we will discuss it in next chapter.
void1.It is a keyword.
2.It indicates that there is no value is returning by the function.
3.If we use any other keyword like int,float,char etc in place of void then we will use return keyword.
main()1.It is the function which is called the entry point of any program.
2.The execution of any program starts from the main function.
3.If in a program there is only one function then it should be main function.
String[] args1.It is an array of type String.
2.It is also called command line argument. can write anything in place of args.
System.out.println1.It is used to print data or information on to the output screen.
2.System.out means Standard output object.
3.println is a method/function.

Post a Comment