Building blocks of Java
Every programming language have some building blocks.Java also have some building blocks ,they are :
- 1.Keywords,
- 2.Identifiers,
- 3.Literals,
- 4.Built-in or predefined
1.Keyword : Keyword is a word having already assigned with predefined task or meaning or purpose. Something you already assigned.
- Ex:class,public,static,void,double,char
- In java all keyword should be typed in lowercase.We have a lot of keywords in java.
2.Identifier : Identifier is a name.which is used to identify.Name to a class or variable or method.
- Ex: variables,arguments
- Main is a reserved identifier to order to execute something .That something should be in main( ) method .
- Main method is a default executable method in java.
- Without main ( ) method we cannot run a program only compilation would be done.
- Public static void are qualifiers for main( ) method.
- Main method arguments should be only (Strings [] args).
- Java has contract with only one method that is main( ).
Rules to follow identify identifiers in java :
- Identifiers should be start with any alphabet,underscore( _ ),Dollar($).From second character not only alphabets,underscore and dollar ,we can also allow digits.No space in name of identifiers,java does not support space in name of identifiers.
- No keyword can be choose d as a identifier.Java does not support keyword as identifier.
Some valid identifiers in java :
Ex: hello,abc,test,helloToAll,_test,$done,hello59,Manager,Student_Test.
Invalid Identifiers in java :
Ex : 20test,test to alle ,class,test@to,hello%to.
Industry conventions under Identifiers :
- Identifiers to a class,interface,enum,annotation start with uppercase.
- Apart from first point (class,interface,enum,annotation)what ever identifier you identify keep it should be in lower case.
- If more than one word is there in any identifier then second word first letter keep in the upper case (from second word on words first letter keep in upper case.
Valid identifiers for class,interface,enum,annotations :
Ex:Hello,Manager,Student, MeritStudent,
Invalid identifiers for class,interface,enum,annotations :
Ex: hello, Meritstudent, helloagain.
Valid identifiers for methods,variables,packages,reference variables :
Ex: test, doSomeThing, calculateSquare, findtheBestAmong
3.Literals : Literal is a value.Any value like int type values ,char type values , double type values , Boolean type values .
- Int type Literals : Ex: 10,20,30,99,-32,0,-998.
- Char type Literals : Ex: a','v','d','k','{','@','9'
- Boolean type Literals : Ex: true ,false
- Double type literals :Ex:1.2,308.9,-12.987,
- Multiple type of literals :
- String Literals : It should be in double quotes " ".
- Ex :"abc","platform","hello user","work"
4.Built in or predefined :
- In Java Development Kit - JDK lot built in or predefined classes are available.
- Every class carrying some predefined task or functionality is there .Thousand together classes are present and available in java .
- Learning of Java is only 30% in development remaining 70% learn for usage of classes and predefined ones only.
- In Java Development Kit - JDK we have an important file called as rt.jar.It containing all predefined classes.Those classes are used in development or composing of java programs.
- Ex:String and,System
- String and System are predefined classes.Which are already defined and developed in java JDK by java developers.