switch (day) {
case 0:
System.out.println("Je pondeli");
break;
case 1:
System.out.println("Je utery");
break;
default:
System.out.println("N/A");
break;
}
if (day == 1) {
System.out.println("Je pondělí");
}
else if (day == 2) {
System.out.println("Je úterý");
}
else {
System.out.printf("N/A");
}
String result = day == 1 ? "Je pondělí" : "Není pondělí";
Integer i = 5;
Integer i2 = 5;
System.out.println(i == i2);
Integer i3 = 128;
Integer i4 = 128;
System.out.println(i3 == i4);
Integer i5 = new Integer(5);
Integer i6 = new Integer(5);
System.out.println(i5 == i6);
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
int i = 10;
while (i < 10) {
System.out.println(i);
}
do {
System.out.println(i);
} while (i < 10);
List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
for (Integer num : list) {
System.out.println(num);
}
public static int factorial(int number) {
if (number < 0) return -1;
if (number == 0 || number == 1) return 1;
return number * factorial(number - 1);
}
public class CsvParserService extends Parser {
...
}
public class CsvParserService extends Parser {
...
}
public interface Movable {
public static final int SPEED_LIMIT = 50;
public void moveForward();
}
public enum Month {
JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY,
AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER;
public static Month getRandom() {
Random r = new Random();
int count = Month.values().length;
return Month.values()[r.nextInt(count)];
}
}
public enum Month {
JANUARY("leden"),
FEBRUARY("únor");
private String nameCZ;
private Month(String nameCZ){
this.nameCZ = nameCZ;
}
}
public interface MyIface<T> {
...
public void test(T test);
}
public vlass MyImpl implements MyIface<String> {
...
public void test(String test) {
}
}