Basic Syntax

Basic Syntax


Posted in : Core Java Posted on : September 28, 2010 at 12:39 PM Comments : [ 0 ]

This section contains the basic general syntax of the java program.

Basic Syntax

The basic syntax of java is some key points, applicable on all java programs, which you need to remember and implement according to syntax :

Case Sensitiveness of Java

Java is case sensitive means it differentiate between same words but having different cases i.e. upper case and lower case. For example : 'Love' and 'love' are different words in java.

Class name Convention :

According to java convention, the first letter of program's name should be in upper case. All other letters can be in any case. The rule is not strictly applied , but you have to follow the convention for better implementation. The program also runs if your program name starts with lower case letter.

See the below example, the program name starts with upper case but it also run if your program name start with upper case :

public class Hello{

   /* by the convention, program name starts with 'H'.
    * This will print 'Welcome in java world' as the output
    */

    public static void main(String []args){
       System.out.println("Welcome in java world"); // prints Hello World
    }
} 

Method naming Convention :

According to java convention, the first letter of the method name start with lower case. The rule is not strictly applied , but you have to follow the convention for better implementation. The program also runs if your method name starts with lower case letter.

Name of the program file :

Name of the program file must be the same as class name. The letters should exactly match. For example, the upper given example should be save in a file as 'Hello.java'. The spelling, upper case letters, lower case letters must be the same. If you will not follow this, the compiler give you a error message.

public static void main(String args[])

The processing of java program starts with main( ).it is a mandatory for every java program. Without it program will not compile successfully.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics