java41 시각과 날짜 코드 ● LocalDate , Period package org.example; import java.time.LocalDate; import java.time.Period; public class Main4 { public static void main(String[] args) { LocalDate today = LocalDate.now(); System.out.println(today); LocalDate xmax = LocalDate.of(today.getYear(),12,25); System.out.println(xmax); LocalDate eve = xmax.minusDays(1); System.out.println(eve); Period left = Period.between(today,xmax.. 2024. 2. 16. 최종연산 2 ● allmatch, anymatch, nonmatch package org.example; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { boolean result = IntStream.of(1, 2, 3, 4, 5) .allMatch(value -> value % 2 == 0); System.out.println(result); System.out.println(); result = IntStream.of(1, 2, 3, 4, 5) .anyMatch(value -> value % 2 == 0); System.out.println(result); System.out.println.. 2024. 2. 16. 스트림의 최종연산 package org.example; import java.util.stream.IntStream; public class Main10 { public static void main(String[] args) { int sum = IntStream.of(1,3,5,7,9) .sum(); System.out.println("sum = "+sum); long count = IntStream.of(1,3,5,7,9) .count(); System.out.println("count = "+count); IntStream.of(1,3,5,7,9) .average() .ifPresent(value -> System.out.println("average = "+value)); IntStream.of(1,3,5,7,9.. 2024. 2. 15. 스트림 2 ● Stream of package org.example; import java.util.Arrays; import java.util.stream.Stream; public class Main8 { public static void main(String[] args) { Stream.of(11, 22, 33, 44, 55) .forEach(System.out::println); //매서드 참조 System.out.println(); Stream.of("so simple") .forEach(System.out::println); System.out.println(); Stream.of(Arrays.asList("11", "aaa", "bbb"), Arrays.asList("test")) .forEach(S.. 2024. 2. 15. 이전 1 2 3 4 5 6 ··· 11 다음