- Co pojawi się na ekranie przy próbie skompilowania i uruchomienia poniższego kodu?
import static java.lang.System.out;
public class JavaLetters {
private static Integer count = 0;
final private static Letter o = Letter.O;
public static void main(String[] args) {
Letter a = Letter.A;
out.println(" JAVA 1." + new JavaLetters().count);
}
static enum Letter {
O, R, A, C, L, E;
private Letter() {
count++;
out.print(this);
}
}
}
Czytaj więcej…
Elvis Presley, legenda rock and rolla. Są tacy, którzy nie przyjmują do wiadomości informacji o jego śmierci; wierzą, że „król” nie umarł i w prywatności wiedzie spokojne życie. A jak to jest naprawdę…
- Co pojawi się na ekranie po uruchomieniu poniższego kodu?
public class Elvis {
// Singleton pattern: there's only one Elvis
public static final Elvis ELVIS = new Elvis();
private Elvis() { }
private static final Boolean LIVING = true;
private final Boolean alive = LIVING;
public final Boolean lives() {
return alive;
}
public static void main(String[] args) {
System.out.println(ELVIS.lives() ?
"Hound Dog" : "Heartbreak Hotel");
}
}
Czytaj więcej…