Java Syntax

Java Syntax is easier to develop code and thus makes Java is the most wanted language in the world. Java allures the Programmers with its simplicity(ease in coding) in learning and programming. The main reason is it does not support pointers. Migrators from C/C++ feel as if floating in the air two feet above the ground level; because they write the linked list program without pointers, adding elements in the middle, adding at head and tail nodes within seconds (not even one minute). If you are new to Java, you will find this when you come to data structures topic.

Do not think I am praising Java because I am a Java trainer; I know at least ten programming languages, but I like Java with its increasing libraries (header files, C++ people call) with every version of Java. Every version of Java (known as JDK versions) adds predefined classes that either decrease programming code or increase the performance. Of course, these are the two aims designers keep in their mind while developing the language further and further.

You can read the unique features of Java and why it is so popular in Java Features – Buzz Words.

Java Syntax

Many C/C++ programmers feel, while learning Java, they know Java earlier (it looks as a familiar face) because much of the syntax of Java is borrowed from C/C++. Like C/C++, Java is a strongly typed language. The same syntax of C/C++ for variables, functions, control structures and arrays is followed by Java.

Like the basic structure of C/C++ is struct, in Java it is class. I feel, a class is a modified form of struct of C-lang. Java supports both global variables (known in Java as instance variables) and local variables. A for loop, a function (in Java, known as method), a if, a switch and a class are separated (delimited) from the remaining part of the code with two braces, opening brace, {, and closing brace, }.

Java does not support preprocessor directives like #define. You are at liberty to write the main() method anywhere in the class, at the beginning of the code or at the end or anywhere. But is it customary to write at the end of the code, just before the class closes. Similarly a method or instance variable can be included anywhere, but being coming from C/C++, we write the variables at the beginning of the code followed by methods (Java does not support prototypes).

To show its simplicity, a small Example given on Java Syntax.
import java.lang.*;
public class Demo
  public static void main(String args[])
    System.out.println("Hello World");
    System.out.println("Best Wishes of the Day");
    System.out.println("I am writing Java Application");

Java SyntaxOutput Screenshot on Java Syntax

For compilation and execution steps with Java syntax explanation see Java Example Compilation Execution

Once you acquainted with the above, slowly go step-by-step into the tutorial of

Leave a Comment

Your email address will not be published.