애너테이션(Annotation)
- 사람에게 주석으로 정보를 제공하듯이 프로그램에게 정보를 제공하는 용도
- 컴파일러에게 문법 에러를 체크하도록
- 프로그램 빌드할 때 코드 자동 생성하도록
- 런타임에 특정 기능을 실행하도록
- 표준 애너테이션/ 메타 애너테이션
- 표준 애너테이션: 자바에서 기본적으로 제공, ex) @Override, @Deprecated @FunctionalInterface, @SuppressWarning
- 메타 애너테이션: 애너테이션을 정의하는데 사용, ex) @Target, @Documented, @Inhreited, @Retention, @Repeatable
- 사용자 정의 애너테이션
람다(lambda)
- 함수형 프로그래밍 기법을 지원하는 자바 문법
- 함수형 인터페이스: 원하는 메서드를 람다식으로 사용하기 위해서 생성하는 하나의 추상형 메서드를 가진 인터페이스
- 자바에서 제공하는 함수형 인터페이스
더보기
Interface Description
BiConsumer<T,U> | It represents an operation that accepts two input arguments and returns no result. |
Consumer<T> | It represents an operation that accepts a single argument and returns no result. |
Function<T,R> | It represents a function that accepts one argument and returns a result. |
Predicate<T> | It represents a predicate (boolean-valued function) of one argument. |
BiFunction<T,U,R> | It represents a function that accepts two arguments and returns a a result. |
BinaryOperator<T> | It represents an operation upon two operands of the same data type. It returns a result of the same type as the operands. |
BiPredicate<T,U> | It represents a predicate (boolean-valued function) of two arguments. |
BooleanSupplier | It represents a supplier of boolean-valued results. |
DoubleBinaryOperator | It represents an operation upon two double type operands and returns a double type value. |
DoubleConsumer | It represents an operation that accepts a single double type argument and returns no result. |
DoubleFunction<R> | It represents a function that accepts a double type argument and produces a result. |
DoublePredicate | It represents a predicate (boolean-valued function) of one double type argument. |
DoubleSupplier | It represents a supplier of double type results. |
DoubleToIntFunction | It represents a function that accepts a double type argument and produces an int type result. |
DoubleToLongFunction | It represents a function that accepts a double type argument and produces a long type result. |
DoubleUnaryOperator | It represents an operation on a single double type operand that produces a double type result. |
IntBinaryOperator | It represents an operation upon two int type operands and returns an int type result. |
IntConsumer | It represents an operation that accepts a single integer argument and returns no result. |
IntFunction<R> | It represents a function that accepts an integer argument and returns a result. |
IntPredicate | It represents a predicate (boolean-valued function) of one integer argument. |
IntSupplier | It represents a supplier of integer type. |
IntToDoubleFunction | It represents a function that accepts an integer argument and returns a double. |
IntToLongFunction | It represents a function that accepts an integer argument and returns a long. |
IntUnaryOperator | It represents an operation on a single integer operand that produces an integer result. |
LongBinaryOperator | It represents an operation upon two long type operands and returns a long type result. |
LongConsumer | It represents an operation that accepts a single long type argument and returns no result. |
LongFunction<R> | It represents a function that accepts a long type argument and returns a result. |
LongPredicate | It represents a predicate (boolean-valued function) of one long type argument. |
LongSupplier | It represents a supplier of long type results. |
LongToDoubleFunction | It represents a function that accepts a long type argument and returns a result of double type. |
LongToIntFunction | It represents a function that accepts a long type argument and returns an integer result. |
LongUnaryOperator | It represents an operation on a single long type operand that returns a long type result. |
ObjDoubleConsumer<T> | It represents an operation that accepts an object and a double argument, and returns no result. |
ObjIntConsumer<T> | It represents an operation that accepts an object and an integer argument. It does not return result. |
ObjLongConsumer<T> | It represents an operation that accepts an object and a long argument, it returns no result. |
Supplier<T> | It represents a supplier of results. |
ToDoubleBiFunction<T,U> | It represents a function that accepts two arguments and produces a double type result. |
ToDoubleFunction<T> | It represents a function that returns a double type result. |
ToIntBiFunction<T,U> | It represents a function that accepts two arguments and returns an integer. |
ToIntFunction<T> | It represents a function that returns an integer. |
ToLongBiFunction<T,U> | It represents a function that accepts two arguments and returns a result of long type. |
ToLongFunction<T> | It represents a function that returns a result of long type. |
UnaryOperator<T> | It represents an operation on a single operand that returnsa a result of the same type as its operand. |
- 메서드 참조 방식
- 클래스 :: 정적 메서드
- 객체 생성 후, 참조 변수:: 인스턴스 메서드
- 생성자 참조. String::new
스트림(Stream)
- 컬렉션 저장 요소를 람다식으로 처리할 수 있도록 하나씩 참조하는 반복자
- 내부 동작을 몰라도 되는 선언형 프로그래밍
- 다양한 메서드를 제공해서 데이터를 다루는 걸 도와줌
- 컬렉션과 배열로 생성, 중간 연산, 최종 연산
- 중간 연산: 필터링(filter(), distinct()), 매핑(map(), flatMap()), 정렬(sorted()), Comparable, 연산 결과 확인(peek())
- 최종 연산: 연산 결과 확인(forEach()), 매칭(match()), 집계(sum(), max(), min(), average(), count()), reduce(), collect()
- map(), flatMap() 차이점: map은 stream의 stream 반환, flatMap은 stream 반환
파일 입출력(I/O)
- 바이트 기반 스트림
- FileInputStream
- FileOutputStream
- 문자 기반 스트림
- FileReader: 인코딩을 유니코드로 변환
- FileWriter: 유니코드를 인코딩으로 변환
- 파일 클래스
- 파일과 디렉토리에 접근
- File.createNewFile()로 파일 생성 가능
참고 출처
https://www.javatpoint.com/java-8-functional-interfaces
'부트캠프 기록 > Section1' 카테고리의 다른 글
[Java] 심화(Effective) 문제풀이/ 18일차 기록 미완 (0) | 2022.09.18 |
---|---|
[Java] 심화(Effective) (0) | 2022.09.18 |
[Java] 컬렉션 페어프로그래밍 회고/ 15일차 기록 (0) | 2022.09.17 |
[Java] 컬렉션 (0) | 2022.09.17 |
[Java] 객체지향 프로그래밍 심화/ 13일차 기록 (0) | 2022.09.09 |