728x90
Arrays.stream( char[] )를 했는데 오류가 났음..
이게 Array.stream()안의 parameter type은
static DoubleStream stream(double[] array)
Returns a sequential DoubleStream with the specified array as its source.
static DoubleStream stream(double[] array, int startInclusive, int endExclusive)
Returns a sequential DoubleStream with the specified range of the specified array as its source.
static IntStream stream(int[] array)
Returns a sequential IntStream with the specified array as its source.
static IntStream stream(int[] array, int startInclusive, int endExclusive)
Returns a sequential IntStream with the specified range of the specified array as its source.
static LongStream stream(long[] array)
Returns a sequential LongStream with the specified array as its source.
static LongStream stream(long[] array, int startInclusive, int endExclusive)
Returns a sequential LongStream with the specified range of the specified array as its source.
static <T> Stream<T> stream(T[] array)
Returns a sequential Stream with the specified array as its source.
이 정도인데 stream으로 다루는 데이터의 타입들 중
자주 쓰이는 실수나 숫자형은 아예 DoubleStream, IntStream, LongStream이 존재함
char는 자주 안쓰이고
CharStream이라는 클래스가 존재를 하지 않아서 Arrays.stream()안의 패러미터로 넣을 수 없는 것임..
또 자주 쓰이는 String형은 primitive가 아니라 Reference클래스기 때문에
Arrays.stream(T[] array)의 Stream형으로 반환함
char형은 원시타입이라 제네릭타입 받는 방식으로 받을 수도 없고,
애초에 받는 paremeter 범위 내에 없기 때문에 불가능..
Wrapper클래스로 바꿔주거나 잠시 int형으로 바꾸던가.. 아니면
내가 풀던 문제는 String에서 toCharArray()활용해 char[]로 쪼갠거니까
String.chars() 메소드를 사용, IntStream을 땡겨와서 그걸로 문제 해결해야함
'무지성 메모' 카테고리의 다른 글
■ Get/ post, put, delete ■ 스프링 기본 파싱 전략 (0) | 2022.03.14 |
---|---|
■ string클래스의 역순 출력 함수 (0) | 2022.03.10 |
■ 소켓통신보다 http통신이 더 비효율적인데 왜 http통신? (0) | 2022.03.08 |
■ @RequestBody는 언제 붙여야 하는가 ■ @Transactional 더티체킹? ■ x-www form-urlencoded json 차이 (0) | 2022.03.07 |
■ yaml파일이란 무엇인가..? (.yml) (0) | 2022.03.04 |