본문 바로가기

명사 美 비격식 (무리 중에서) 아주 뛰어난[눈에 띄는] 사람[것]

JAVA

(360)
스트림 - 바이트기반 스트림: FileInputStream/FileOutputStream ByteArrayInputStream/ByteArrayOutputStream PipedInputStream/PipedOutputStream AudioInputStream/AudioOutputStream 앞서 스트림과 입출력에 대해 배워봤다. https://standout.tistory.com/106 스트림이란? Stream 개울, 흘러가는것, 가는길 데이터를 운반하는데 사용되는 연결통로 https://ko.wikipedia.org/wiki/%EC%8A%A4%ED%8A%B8%EB%A6%BC 스트림 - 위키백과, 우리 모두의 백과사전 위키백과, 우리 모두의 백과사전. standout.tistory.com https://standout.tistory.com/53 표준입출력, System.in, System.out, System.err I/O Input과 Output 입력과 출력, 입출력 컴퓨터 내부, 외부 장치와 프로그램간의 데이터를 주고받는것. 표준 스트림(standard streams) 컴퓨터 시스템의 ..
스트림의 변환 총정리: 언제 어떤 메서드를 써야하는가. 스트림으로 프로그램을 작성할때 어려움은 스트림간의 변환, 그리고 언제어떤 메서드를 써야하는지 매번 찾아보는것이다. 표로 간단히 정리하여 앞으로 스트림 - 스트림간의 변환에 관련된 이슈때 유용하도록 하자. from to 변환메서드 스트림 → 기본형 스트림 Stream IntStream LongStream DoubleStream mapToInt(ToIntFunction mapper) mapToLong(ToLongFunction mapper) mapToDouble(ToDoubleFunction mapper) 기본형 스트림 → 스트림 IntStream LongStream DoubleStream Stream Stream Stream boxed() Stream mapToObj(DoubleFunction mapper..
Collector 구현하기, 예시코드 Collector를 구현하려면 Collector 인터페이스를 구현해야한다. public interface Collector - `T`: 수집될 요소의 타입 - `A`: 중간 결과를 누적할 객체의 타입 - `R`: 최종 결과의 타입 public interface Collector { Supplier supplier(); //누적할 객체를 생성하는 함수를 반환 BiConsumer accumulator(); //스트림의 각 요소를 누적하는 함수를 반환 BinaryOperator combiner(); //병렬 실행 시 두 개의 누적 객체를 병합하는 함수를 반환 Function finisher(); //중간 결과를 최종 결과로 변환하는 함수를 반환 Set characteristics(); //Collector의 ..
collect() 그룹화/분할하다: groupingBy() partitioningBy() groupingBy() 주어진 함수에 따라 스트림의 요소들을 그룹화. 각 그룹은 함수의 결과에 따라 맵의 키로 표현된다. import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) { Stream stream = Stream.of("Apple", "Banana", "Orange", "Apricot", "Avocado"); // 문자열의 길이에 따라 그룹화 Map result = stream.collect(Collectors.groupingBy(String::l..
collect() 문자열을 결합하다: joining() joining() 메서드는 스트림의 요소들을 하나의 문자열로 결합하는데 사용. 아래예시에서는 스트림의 요소들을 하나의 문자열로 결합했다. import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) { Stream stream = Stream.of("Apple", "Banana", "Orange"); String result = stream.collect(Collectors.joining()); System.out.println("Result: " + result); // 출력: AppleBananaOrange } } 만약 각 요소 사이에 ..
collect() 통계정보를 얻다: counting() summingInt() averagingInt() maxBy() minBy() counting() 스트림의 요소 개수를 세는데 사용. import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) { Stream stream = Stream.of("Apple", "Banana", "Orange"); long count = stream.collect(Collectors.counting()); System.out.println("Count: " + count); // 출력: 3 } } summingInt() 스트림의 요소를 정수로 변환하여 합계를 구하는데 사용. import java.util.stream.Collectors..
collect() 스트림을 컬렉션과 배열로 전환하다: toList() toSet() toMap toCollection() toArray() 앞서 collect()의 기본 문법에 대해 알아봤다. toList()를 사용하여 최종연산을 확인해봤는데 외 전환방법을 확인해보자. https://standout.tistory.com/1463 collect(), 매개변수로 스트림을 최종연산하다: Object collect(Collector collector) Object collect(Supplier supplier 앞서 collect()와 reduce()를 배웠다. https://standout.tistory.com/1447 스트림의 연산 - 최종연산 forEach forEachOrdered count max min findANy findFirst allMatch anyMatch noneMatch toArray re 앞서 스트림과 스트림의 연산에 대해 ..
collect(), 매개변수로 스트림을 최종연산하다: Object collect(Collector collector) Object collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner). (feat. 매개변수가 3개인 collect) 앞서 collect()와 reduce()를 배웠다. https://standout.tistory.com/1447 스트림의 연산 - 최종연산 forEach forEachOrdered count max min findANy findFirst allMatch anyMatch noneMatch toArray re 앞서 스트림과 스트림의 연산에 대해 알아봤다. 데이터를 최종 추출하는 스트림 최종연산의 종류에 대해 알아보자. https://standout.tistory.com/1445 스트림의연산, 중간 연산과 최종연산 스트림 데이 standout.tistory.com collect()는 reduce()와 유사하다. 스트림의 모든 요소를 결합하여 단일 결과를 생성하는 최종 연산. import java.util.st..