Blog

Java Basic Syntax

Before you start your java program you need to learn the basic syntax first, the below are the basic syntax

Basic Java syntax rules

What is Body in Java?

{} parenthesis means body in java

Every Class, Method and Loop will have a body.

Is Java Case Sensitive?

Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.

Class Names should be upper case?

For all class names the first letter should be in Upper Case. 

public class FirstProgram {

}

Why package names lower case?

Package names should be always lower case because class names starts with Upper case to differentiate package names with class names the package names are recommended to be lower cases

Why Method names starts with lower case?

All method names should start with a Lower Case letter If several words are used to form the name of the method, then each inner word’s first letter should be in Upper Case.

Example:

public void firstMethod() {

}

Why Camel case?

If you use several words to form a name of the class, each inner word’s first letter should be in Upper Case.

Example:

public class FirstProgram {

}

Program File Names

Name of the program file should exactly match the class name. When saving the file, you should save it using the class name (Remember Java is case sensitive) and append ‘.java’ to the end of the name (if the file name and the class name do not match, your program will not compile).

Example:

Assume ‘FirstJavaProgram’ is the class name. Then the file should be saved as ‘FirstJavaProgram.java’

Leave a Reply

Your email address will not be published. Required fields are marked *