/** * DATA TYPES * Primitive and Reference * 8 Types , All Objects */
All programmer must know about data types. Primitive Types : 1. char 2. boolean 3. byte 4. short 5. int 6. long 7. float 8. double
/** * DATA TYPES LAW * */
Three laws of number primitive type java.
LAW One: Long to Int lData = (long)iData //Optional Cast , Implicit Cast, upCast Bigger type can't assign to smaller type = Solution is casting. LAW Two: int && smaller than of int that calculate result type is int int && bigger than of int that calculate result type is bigger type LAW Three: long; float; lData = fData; //Can't assign All int type can assign to all floating type but all floating type can't assign to all int type => NO Solution Read in numbering system.
Literals
//Literals definations => int i = 100; //100 is called Literals //Binary => 0b //Octal => 0 ==> Start with Zero Preface //Hexa => 0x , 0X int literal = 0b100 => 4 literal = 0b101
/** * OPERATORS */ Four Operators : 1. Assignment : = , += , -=, *=, /= 2. Arithmetic : +, -, *, /, %, ++, -- . { Pre ++a n Post a++ } 3. Relational : <, <=, >, >=, !=, == . { Result will be return by Boolean } 4. Logical : !, & {If one false, all false} , && {Only Works First one}, || { First and Second work, not third } ,Solution for work firstly use Parenthesis. ^ { If not same, return true }, // If there is no parenthesis it will work " x / + - ", // But same level x, / n %. For start work use Parenthesis for same level's.
/** * Expressions */
5 + 3 = 8 {Expression} Statements int result = 5 + 3;
/**
* LOCAL VARIABLE
*/
In this local variable , we can't use access modifier like static, private and public. final can use and must initialize or assign value.
Class is Static Object is Instance /** * METHODS */ ' Two methods type : return type and void (noReturn)
Harder than Ever.
Art of Programming !