java syntax

Java Basic Syntax | Java Tutorial

In this tutorial, we will learn about Java Syntax in detail or Step by step explanation.

A Java program can be considered as a collection of objects that communicate by invoking each other’s methods. Let’s take a quick look at what class, object, methods, and instance variables are and what they mean.

1: Object

  • The object is a class instance with behavior and state. A vehicle, for example, is an object with the following states: brand, color, and number plate.
  • Running on the road is a common occurrence or behavior.

2: Class

  • A class is a template/blueprint that describes the behavior/state that an object of its type supports.

3: Methods

  • A behaviour is what a method is. Many methods can be found in a single class. Methods are where logic is written, data is manipulated, and all actions are carried out.

4: Instance Variables 

  • Every object has a set of instance variables that are unique to it. The values that are assigned to these instance variables usually determine the state of an object.

To run a java program and compile in a console- Run this Command:

java filename
java DevelopersDome
public class DevelopersDome { 
  public static void main (String[] args) {



Basic Java Syntax

Class NamesThe first letter of each class name should be capitalized. If a class name is made up of several words, the first letter of each inner word should be in upper case.
Method Names All method names should begin with a letter in lower case. If the method’s name is made up of several words, the first letter of each inner word should be capitalized.
Case Sensitivity Java is case-sensitive. In Java, hello and hello would have different meanings.
public static void main(String args[])The main() method, which is required in every Java program, is where the processing of the program begins.
Program File NameThe program file name should be similar to the class name.
When saving the file, use the class name and append ‘.java’ to the end of the name (remember, Java is case sensitive) (if the file name and the class name do not match, your program will not compile.
Identifiers in javaAll identifiers can begin with a letter (A to Z or a to z) or an underscore ( _ ) .first character can be any combination of characters.
The most important thing to remember is that identifiers are case-sensitive.
Because a keyword is a reserved word with a specific meaning, it cannot be used as an identifier.
White-spaces in JavaA blank line is a line that contains only whitespaces, possibly with a comment, and the Java compiler ignores it completely.
Access ModifiersThe scope of a class and its methods is controlled by these modifiers.
default, public, protected, and private are all-access modifiers.
final, abstract, strictfp are non-access modifiers. 

Comments in Java

 1: Single line Comment

// DevelopersDome

2: Multi-line Comment

java DevelopersDome

Java Keywords

The following is a list of Java reserved words. These reserved words may not be used as names for constants, variables, or other types of identifiers.

import while intinterface


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

  • Every line of Java code must be contained within a class. We called the class Main in our example. The first letter of a class should always be capitalized.
  • Note that Java is case-sensitive, so “ExampleClass” and “exampleclass” are not interchangeable.
  • The java file must have the same name as the class. When saving the file, use the class name as the filename and add “.java” to the end.  


Hello world!!
  • main Method
public static void main(String[] args)
  • Any code contained within the main() method will be run.  
  • For the time being, just keep in mind that every Java program must have a class name that matches the filename and that every program must have the main() method.
  • System.out.println()
System.out.println(“Hello World!!”);

  • We hope that this article will assist you in understanding all about the Java syntax. We have concentrated on making a basic, meaningful, and easy-to-learn guide to the concepts. Still, if you have any problems regarding this, please post them in the comment section, we will be glad to assist you.

java syntax, java syntax , java syntax , java syntax ,v,v, java syntax , java syntax , java syntax , java syntax ,v, java syntax , java syntax , java syntax , java syntax , java syntax , java syntax

This Post Has 11 Comments

  1. Odeyemi favour abosede

    Explanations are comprehensive enough but can I get any video that explains the java compiler usage or basically the writing of the java programs

Leave a Reply