Thursday, October 13, 2011

Learn Java in Easy Steps

Learn Core JAVA in Easy Steps [Page 5]





Conditional Constructs :-

  1. Switch
  2. If
  3. If Else
  4. If Else If ladder
  5. nested If

Looping :-
  1. While
  2. Do While
  3. For
  4. For each





--> Switch :=
switch(expression){
case 1:
statements;break;
case 2:
statements;break;
.... 
default:
statements;
}





--> If :=
if(condition){
statements;
}

--> If Else :=
if(condition)
{}
else
{}

--> If - Else - If :=
if(){

}else if(){

}else{

}

--> Nested If :=
if(){
if()
{}
}

--> While :=
while(condition){
}

--> Do While :=
do{}while(condition)
--> For :=
for(start, end, condition){} 

--> For Each :=
for(String Devharsh:array)
System.out.println(Devharsh);

Learn Core JAVA in Easy Steps [Page 4]





Operators:

1. Arithmetic
 - Assignment
 - Increment
 - Decrement

2. Relational
 - Boolean

3. Logical
 - Short Circuit
 - Long Circuit


PriorityOperatorsOperationAssociativity
1[ ]array indexleft
()method call
.member access
2++pre- or postfix incrementright
--pre- or postfix decrement
+ -unary plus, minus
~bitwise NOT
!boolean (logical) NOT
(type)type cast
newobject creation
3* / %multiplication, division, remainderleft
4+ -addition, substractionleft
+string concatenation
5<<signed bit shift leftleft
>>signed bit shift right
>>>unsigned bit shift right
6< <=less than, less than or equal toleft
> >=greater than, greater than or equal to
instanceofreference test
7==equal toleft
!=not equal to
8&bitwise ANDleft
& boolean (logical) AND
9^bitwise XORleft
^ boolean (logical) XOR
10|bitwise ORleft
| boolean (logical) OR
11&&boolean (logical) ANDleft
12||boolean (logical) ORleft
13? :conditionalright
14=assignmentright
*= /= += -= %=
<<= >>= >>>=
&= ^= |=
combinated assignment
(operation and assignment)