- Decision making if else if, switch
Repetitive making while do while for
Decision Making
int h1 = 170, h2 = 175;
if (h1>h2) {
System.out.println (h1);
}
else if (h2>h1) {
System.out.println (h2);
}
else {
System.out.println (“Same”);
}
Conditional statements:
If, if else, else, switch case, nested
Nested condition : if inside if inside if, can write n number of if and then else etc
Switch condition : case 1 break; case 2 break; case 3 break; finally default and print statement. Datatypes used: [ int, string, enum ]
2.Repetitive Making
While loop – Entry criteria looping
Int no =1; count =1;
While (count <= 5) {
System.out.println (no);
Count++;
}
Do while loop – Exit Criteria Looping
Int no =1; count =1;
Do{
System.out.println (no);
Count++;
While (count <= 5);
}
For Loop
Int no = 1;
for (int count = 1, count <=10, count ++) {
system.out.println (no);
}
Top comments (0)