public class Test {
public static void main(String[] args) {
int i = 0;
method(i);
System.out.print(i);
StringBuilder sb = new StringBuilder();
sb.append("1");
method2(sb);
System.out.print(sb);
}
public static void method(int val) {
val = 1;
}
public static void method2(StringBuilder sb) {
sb.append("2");
sb = new StringBuilder();
sb.append("3");
}
}❤3
🎉5
import java.util.Random;
public class Test {
private static Random rnd = new Random();
public static void main(String[] args) {
StringBuffer word = null;
switch (rnd.nextInt(2)) {
case 1: word = new StringBuffer('P');
case 2: word = new StringBuffer('G');
default: word = new StringBuffer('M');
}
word.append('a');
word.append('i');
word.append('n');
System.out.println(word);
}
}
🎉3
public class Test {
public static void main(String[] args) {
int j = 0;
for (int i = 0; i < 100; i++) {
j = j++;
}
System.out.println(j);
}
}👍3❤1
❤5🤡5👍2🎉1
import java.io.IOException;
public class Test {
public static void main(String[] args) {
try {
System.out.println("Hello World");
} catch (IOException e) {
System.out.println("Error");
}
}
}
❤4🥱1
❤7👎4🤡4🎉2
class Cat {
public static void mew() {
System.out.print("Meow");
}
}
class SimonsCat extends Cat {
public static void mew() { }
}
public class Mew {
public static void main(String[] args) {
Cat cat = new Cat();
Cat simonsCat = new SimonsCat();
cat.mew();
simonsCat.mew();
}
}👍3❤1
🎉4
public class Test {
public static void main(String[] args) {
double d = 1 / 3;
System.out.print(d);
}
}❤1
🎉5🔥2
public class CurrentYear {
public static final CurrentYear INSTANCE = new CurrentYear();
private final int diff;
private static final int CURRENT_YEAR = Calendar.getInstance().get(Calendar.YEAR);
public CurrentYear() {
diff = CURRENT_YEAR - 2025;
}
public int getDiff() {
return this.diff;
}
public static void main(String[] args) {
System.out.println(INSTANCE.getDiff());
}
}👍2
🎉2
package a.b;
public class Ku {
public static void main(String[] args) {
System.out.println(Ku.class.getName().replaceAll(".", "/") + ".class");
}
}
❤4
🎉3👏1
public class Test {
public static void main(String[] args) {
System.out.println(toBeOrNotToBe());
}
static boolean toBeOrNotToBe() {
try {
return true;
} finally {
return false;
}
}
}❤3🎉1
public class Boom {
private Boom internalInstance = new Boom();
public Boom() throws Exception {
throw new Exception("Boom!");
}
public static void main(String[] args) {
try {
Boom b = new Boom();
System.out.println("Surprise");
} catch (Exception e) {
System.out.println("I caught!");
}
}
}❤2
Что выведет код? 👆
Anonymous Quiz
22%
Boom!
20%
Surprise
34%
I caught!
24%
<Ошибка StackOverflowError>
🎉5❤1👍1