text
stringclasses 10
values | metadata
dict |
---|---|
<java8_code>: public class Example { public static void main(String[] args) { int x = 10; System.out.println(x); } }
<java17_code>: public class Example { public static void main(String[] args) { var x = 10; System.out.println(x); } } | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: public class SwitchExample { public static void main(String[] args) { int day = 1; String dayName; switch (day) { case 1: dayName = "Monday"; break; case 2: dayName = "Tuesday"; break; default: dayName = "Other"; } System.out.println(dayName); } }
<java17_code>: public class SwitchExample { public static void main(String[] args) { int day = 1; String dayName = switch (day) { case 1 -> "Monday"; case 2 -> "Tuesday"; default -> "Other"; }; System.out.println(dayName); } } | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: public class Person { private final String name; private final int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public int getAge() { return age; } }
<java17_code>: public record Person(String name, int age) { } | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: public abstract class Shape { } public final class Circle extends Shape { } public final class Square extends Shape { }
<java17_code>: public sealed class Shape permits Circle, Square { } public final class Circle extends Shape { } public final class Square extends Shape { } | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: List<String> list = new ArrayList<>(); list.add("apple"); list.add("orange"); for (String fruit : list) { System.out.println(fruit); }
<java17_code>: var list = List.of("apple", "orange"); list.forEach(System.out::println); | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: Path path = Paths.get("/tmp/file.txt"); try { List<String> lines = Files.readAllLines(path); lines.forEach(System.out::println); } catch (IOException e) { e.printStackTrace(); }
<java17_code>: var path = Path.of("/tmp/file.txt"); try { var lines = Files.readAllLines(path); lines.forEach(System.out::println); } catch (IOException e) { e.printStackTrace(); } | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: List<Integer> numbers = Arrays.asList(1, 2, 3, 4); Optional<Integer> max = numbers.stream().max(Integer::compareTo); System.out.println(max.orElse(-1));
<java17_code>: var numbers = List.of(1, 2, 3, 4); var max = numbers.stream().max(Integer::compareTo); System.out.println(max.orElse(-1)); | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: public class OldThread { public static void main(String[] args) { Thread t = new Thread(new Runnable() { public void run() { System.out.println("Hello from a thread"); } }); t.start(); } }
<java17_code>: public class NewThread { public static void main(String[] args) { var t = new Thread(() -> System.out.println("Hello from a thread")); t.start(); } } | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: Comparator<String> comparator = new Comparator<String>() { @Override public int compare(String s1, String s2) { return s1.compareTo(s2); } };
<java17_code>: Comparator<String> comparator = String::compareTo; | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
<java8_code>: Stream.of(1, 2, 3, 4).filter(i -> i % 2 == 0).forEach(System.out::println);
<java17_code>: var stream = Stream.of(1, 2, 3, 4); stream.filter(i -> i % 2 == 0).forEach(System.out::println); | {
"input_language": "java8",
"output_language": "java17",
"source": "unified_chip2"
} |
README.md exists but content is empty.
- Downloads last month
- 32