예:
record Record(Integer x, String y) {
}
public static void test(List<Record> records) {
for (Record record : records) {
System.out.println(record.y());
Integer x = record.x;
System.out.println(x);
}
}
다음으로 대체 가능:
record Record(Integer x, String y) {
}
public static void test(List<Record> records) {
for (Record(Integer x, String y) : records) {
System.out.println(y);
System.out.println(x);
}
}
for 문에서 사용되지 않는 구성 요소의 최대 수를 지정합니다2023.1의 새로운 기능