확인법

Programming/Java

[Java] 변수의 타입을 확인하는 방법

Generic을 공부하다가 문득 내가 선언한 변수의 타입이 궁금하여 타입을 콘솔에 출력하는 방법을 찾아보았다. 변수명.getClass().getName() example) public class CheckType { public static void main(String[] args) { Integer i = 123; Double d = 123.123; Character c = 'a'; String s = "asdf"; ArrayList arrayList = new ArrayList(); LinkedList linkedList = new LinkedList(); HashSet hashSet = new HashSet(); TreeSet treeSet = new TreeSet(); HashMap hashMa..

Smile :DK
'확인법' 태그의 글 목록