Type Casting
Widening Casting
- done automatically
Narrowing Casting
code example
double myDouble = 9.78d;
int myInt = (int) myDouble;
What is the four key control flow statements in Java?
switch statement
switch (expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
break;
}for statement
syntax:
for (init; condition; increment) {
// statements
}while statement
syntax:
while (condition) {
// statements
}do-while statement
do {
// statements
} while (condition);continue
continue
break
What are the difference between while and do-while statements?