https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html
Class (Java Platform SE 8 )
Determines if the specified Class object represents a primitive type. There are nine predefined Class objects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types tha
docs.oracle.com
Class<T>에 접근하는 방법 ?
- 모든 클래스는 로딩 후 Class<T> 인스턴스가 생긴다.
- -> "타입.class"로 접근
-
Class<Member> aClass = Member.class; // (1)
- 모든 인스턴스는 getClass() 메소드를 가지고 있다
- -> "인스턴스.getClass()"로 접근
-
Member member1 = new Member(); Class<? extends Member> bClass = member1.getClass(); // (2)
- 클래스 문자열로 읽어오는 방법
- Calss.ForName("패키지 + 클래스 명")
-
Class<?> cClass = Class.forName("hudi.reflection.Member"); // (3)
Class<T>를 통해 할 수 있는 것 ? - 해당 함수 참고
- 필드 (목록) 가져오기
- 메소드 (목록) 가져오기
- 상위 클래스 가져오기
- 인터페이스 (목록) 가져오기
- 어노테이션 가져오기
- 생성자 가져오기 ...
'프로그래밍 언어 > 자바(JAVA)' 카테고리의 다른 글
자바(람다) - removeif (0) | 2024.05.29 |
---|---|
간단한 HTTP 프로토콜 구현. (0) | 2022.07.28 |
http 프로토콜 소켓을 이용한 직접 구현(웹브라우저 구현 원리) (0) | 2022.05.23 |
자바 컴파일러가 공짜로 해주는 거 (0) | 2022.05.02 |
자바 함수 만드는 법 (0) | 2022.04.15 |