Chapter 3
Chapter 3
Java
Revised 2nd Edition
Sachin Malhotra & Saurabh Choudhary
•Illegal Identifiers
- My Class
- 23amount
- -totalpay
- total@commission
and suffix
- Can be applied to Boolean operands (or expressions) and return a boolean value.
- logical OR (|),
int x=2,y=3;
System.out.println(“Bitwise OR : “+x+”|”+y+”=”+(x|y));
}}
• Bitwise OR : 2|3=3
b= 1 s= 1
i=4
• Loops
• Branching statements
• Exceptions (chap 9)
for(int i=1;i<=5;i++)
}
© Oxford University Press 2018. All rights reserved.
The Output
The output is as follows:
Square of 1 is 1
Square of 2 is 4
Square of 3 is 9
Square of 4 is 16
Square of 5 is 25
Square of 1 is 1
Square of 2 is 4
Square of 3 is 9
Square of 4 is 16
Square of 5 is 25
Square of 1 is 1
Square of 2 is 4
Square of 3 is 9
Square of 4 is 16
Square of 5 is 25
// Statements to repeat
• But unlike them, for-each loop determines its number of steps from
the size of the collection.
//dosomething;