This file contains hidden or 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 Test { | |
public static void main(String[] args) { | |
System.out.println(3 + 4 * 2 > 2 * 9); | |
System.out.println(Math.pow(4, 0.5)); | |
System.out.println((int) (Math.random())); | |
System.out.println(34 % 7); | |
int y = -1; | |
System.out.println(x / 100); | |
System.out.println(x % 100); | |
System.out.println(++y); |
This file contains hidden or 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
char ch = 'a'; | |
switch (ch) { | |
case 'a': | |
case 'A': | |
System.out.print(ch); break; | |
case 'b': | |
case 'B': | |
System.out.print(ch); break; | |
case 'c': | |
case 'C': |
This file contains hidden or 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
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n, p, q; | |
n = sc.nextInt(); | |
p = n / 16; | |
q = n % 16; | |
if (q == 10) | |
System.out.println(p + "" + "a"); |
This file contains hidden or 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 Test { | |
public static void main(String[] args) { | |
int[] x = new int[5]; | |
int i; | |
for (i = 0; i < x.length; i++) | |
x[i] = i; | |
System.out.println(x[i]); | |
} | |
} |
This file contains hidden or 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 Main { | |
public static void main(String[] args) { | |
System.out.print('a' + Math.random() * ('z' - 'b')); | |
} | |
} |
This file contains hidden or 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 Main { | |
public static void main(String[] args) { | |
System.out.println(m1(10, 17)); | |
} | |
static long m1(long a1, long a2) { | |
long aux = 1; | |
while (a2 > 0) { | |
if (a2 % 2 == 1) { | |
aux *= a1; |
This file contains hidden or 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
int count = 0; | |
do { | |
System.out.println("Welcome to Java"); | |
count++; | |
} while (count < 10); |
This file contains hidden or 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 Test { | |
public static void main(String[] args) { | |
int i = 1; | |
while (i <= 4) { | |
int num = 1; | |
for (int j = 1; j <= i; j++) { | |
System.out.print(num + "bb"); | |
num *= 3; | |
} | |
System.out.println(); |
This file contains hidden or 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 Test { | |
public static void main(String[] args) { | |
int[] list = {1, 2, 3, 5, 4}; | |
for (int i = 0, j = list.length - 1; i < list.length; i++, j--) { | |
// Swap list[i] with list[j] | |
int temp = list[i]; | |
list[i] = list[j]; | |
list[j] = temp; | |
} | |
System.out.print(java.util.Arrays.toString(list)); |
This file contains hidden or 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 Test { | |
public static void main(String[] args) { | |
System.out.println("Number of strings is " + args.length); | |
for (int i = 0; i < args.length; i++) | |
System.out.println(args[i]); | |
} | |
} |
OlderNewer