Basic Syntax

Compiled By Unknown - No Comments
Java Keywords
 public class CommentsAndSlashes  
 {  
   public static void main( String[] args )  
   {  
     // A comment, this is so you can read your program later.  
     // Anything after the // is ignored by Java.  
     System.out.println( "I could have code like this." ); // and the comment after is ignored.  
     // You can also use a comment to "disable" or comment out a piece of code:  
     // System.out.println("This won't run.");  
     System.out.println( "This will run." );  
   }  
 }  


 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  
   }  
 }   

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.
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.

Tags:

No Comment to " Basic Syntax "