Basics of Java


Syntax of Java

About java programs,it is very important to keep in mind the following points

Case Sensitivity

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

Class Name

For all class names the first letter should be in Upper Case.
I. If several words are used to form a name of the class ,each inner word's first letter should be in Upper case.
II. Example class MyFirstJavaClass

Method Name

All method names should start with a Lower case letter.
I. If several words are used to form the name of the method,then each inner word's first letter should in Upper case.
II.Example public void myMethodName()

Program File Name

Name of the program file should exatly match the class nae.
I. When saving the file,youshould save it using the class name and append'.Java'to the end of the name.
II. Example : Assume 'MyFirstJavaProgram'is the class name. Then the file should be saved as "MyFirstJavaProgram.java"

public static void main(String args[])

Java program processing starts from the main() method which is a mandatory part of every Java program.

Comments in Java

The java language supports three types of comments
/*text*/ the compiler ignores everything from?8 to */ /**documentation**/ This indicates a documentation comment.comment. The compiler ignores this kind of comment, just like it ignores comments that use /*and*/.The JDK java doc tool uses doc comments when preparing automatically generated documentation. //text The compiler ignores everything from // to the end of the line.

Reserved keywords in Java

Keywords are special tokens in the language which have reserved use in the language. Keywords may not be used as identifier in Java. You cannot declare a field whose name is a keyword ,for instance
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment