File tree 5 files changed +58
-0
lines changed
5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ //Java Program to illustrate the use of continue statement
2
+ //inside an inner loop
3
+ public class Continue {
4
+ public static void main (String [] args ) {
5
+ //outer loop
6
+ for (int i =1 ;i <=3 ;i ++){
7
+ //inner loop
8
+ for (int j =1 ;j <=3 ;j ++){
9
+ if (i ==2 &&j ==2 ){
10
+ //using continue statement inside inner loop
11
+ continue ;
12
+ }
13
+ System .out .println (i +" " +j );
14
+ }
15
+ }
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ public class DoWhile {
2
+ public static void main (String [] args ) {
3
+ do {
4
+ System .out .println ("infinitive do while loop" );
5
+ }while (true );
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ public class ForLoop {
2
+ public static void main (String [] args ) {
3
+ for (int i =1 ;i <=5 ;i ++){
4
+ for (int j =1 ;j <=i ;j ++){
5
+ System .out .print ("* " );
6
+ }
7
+ System .out .println ();//new line
8
+ }
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ //A Java Program to demonstrate the use of if-else statement.
2
+ //It is a program of odd and even number.
3
+ public class IfElseExample {
4
+ public static void main (String [] args ) {
5
+ //defining a variable
6
+ int number =13 ;
7
+ //Check if the number is divisible by 2 or not
8
+ if (number %2 ==0 ){
9
+ System .out .println ("even number" );
10
+ }else {
11
+ System .out .println ("odd number" );
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ public class WhileLoop {
2
+ public static void main (String [] args ) {
3
+ // setting the infinite while loop by passing true to the condition
4
+ while (true ){
5
+ System .out .println ("infinitive while loop" );
6
+ }
7
+ }
8
+ }
9
+
10
+
You can’t perform that action at this time.
0 commit comments