Created
February 16, 2020 22:21
-
-
Save alimuhammed056/a5df4d3208d0389961fa01f9db6b03b7 to your computer and use it in GitHub Desktop.
Java3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewClass { | |
public static void main(String[] args) { | |
int x = 3; | |
int y = 4; | |
int z = 5; | |
if(x>y && x>z){ | |
System.out.println("Ok"); | |
}else if(y>x && y>z){ | |
System.out.println("OK OK"); | |
}else{ | |
System.out.println("Ok ok Ok"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*/ | |
public class NewClass1 { | |
public static void main(String[] args) { | |
int x = 17; | |
switch (x) { | |
case 8: | |
case 7: | |
System.out.println("8 or 7"); | |
break; | |
default: | |
System.out.println("Default"); | |
break; | |
case 3: | |
System.out.println("3"); | |
break; | |
case 5: | |
System.out.println("5"); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewClass2 { | |
public static void main(String[] args) { | |
//Looping Statements | |
int i = 0; | |
for (; i < 3; i++) { | |
System.out.println(i); | |
} | |
System.out.println("Last value of i = "+i); | |
} | |
} | |
/* | |
i o/p | |
--------------------------------- | |
0 Java | |
1 Java | |
2 Java | |
3 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewClass3 { | |
public static void main(String[] args) { | |
for (int i = 0; i < 101; i++) { | |
if (i == 0) { | |
System.out.println(i + " zero"); | |
} else if (i % 2 == 0) { | |
System.out.println(i + " even"); | |
} else { | |
System.out.println(i + " odd"); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewClass4 { | |
public static void main(String[] args) { | |
for (int i = 0; i < 101; i+=2) { | |
System.out.println(i+" "+(101-i)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewClass5 { | |
public static void main(String[] args) { | |
int sum = 0; | |
for (int i = 0; i < 101; i++) { | |
sum = sum + i; | |
} | |
System.out.println(sum); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewClass6 { | |
public static void main(String[] args) { | |
for (int i = 0; i < 3; i++) { | |
for (int j = 0; j < 3; j++) { | |
//System.out.println(i+" "+j); | |
System.out.print("*"); | |
} | |
System.out.println(""); | |
} | |
} | |
} | |
/* | |
i j o/p | |
0 0 *** | |
0 1 | |
0 2 | |
0 3 | |
//----------------------------- | |
1 0 *** | |
1 1 | |
1 2 | |
1 3 | |
//------------------------ | |
2 0 *** | |
2 1 | |
2 2 | |
2 3 | |
---------------------------- | |
3 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment