본문 바로가기 메뉴 바로가기
[Java] 자바 - 제네릭(Generic)

자바(Java)에서 제네릭(Generic)은 클래스 내부에서 사용하는 데이터의 타입(Type)을 클래스의 인스턴스를 생성할 때 결정하는 것을 의미합니다. 객체의 타입을 컴파일 시점에 체크하기 때문에 타입 안정성을 높이고 형 변환의 번거로움을 줄일 수 있습니다. 아래 간략하게 제네릭(Generic)을 사용하여 선언된 클래스와 객체를 선언한 부분을 살펴보겠습니다. public class TestGeneric { public T sample; public void showYourType() { if(sample instanceof Integer) System.out.println("Integer 타입이군요!!"); else if(sample instanceof String) System.out.println(..

Programming/JAVA 2019. 6. 16. 13:30
이전 1 다음
이전 다음

티스토리툴바

이메일: help@abaeksite.com | 운영자 : 아로스
제작 : 아로스
Copyrights © 2022 All Rights Reserved by (주)아백.