Skip to content

antksk/java8-training

Repository files navigation

java8-training

Java8를 사용한지 2년이 넘어가지만 나름 정리한 내용이, 이곳 저곳에 흐터져 있어 이곳에 재 정리함

build

  • eclipse sts 기반 프로젝트로 생성
gradle eclipse

Java8로 적용 샘플 코드 목차

  • stream: 일종의 pipeline으로 연속적인 어떤 데이터의 흐름을 가르킴, Stream 연산 들은 중간 연산(intermediate operation) 이거나 결과 값을 리턴하는 종단 연산(terminal operation) 이다.
    • filter filter(Predicate<? super T> predicate): 지정된 predicate의해서 지정된 값과 일치(match)한 값들만 취합
    • sorted sorted(Comparator<? super T> comparator): stream에 정렬에 대한 마킹만 하고 실제 정렬은, 종단 연산이 수행될때 진행됨(기본은 오름차순정렬)
    • map map(Function<? super T, ? extends R> mapper): 지정된 strem의 데이터를 임의 데이터로 변경
    • (terminal) forEach(Consumer<? super T> action) : (소비) 각각의 데이터를 모두 소비
    • (terminal) match : any(아무거나 한개 이상 match), all(모두 match), none(한개도 match되지 않음) match가 존재 하며, 소비 함수 임
    • (terminal) count : stream에 존재하는 element 갯수 확인(소비, long 타입으로 리턴)
    • (terminal) reduce : 결합법칙(결합하는 순서는 중요하지 않아야 함)이 적용된 결과값을 리턴

참고 자료

java8-training

Java8에 추가된 여러 기능 테스트

About

Java8에 추가된 여러 기능 테스트

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages