* Programming/JAVA
DAY20 Object클래스,리플렉션
고경a
2016. 8. 2. 19:41
20일차 강의 정리
소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | class Pm01{//extends Object // public Pm01(){ //숨어있는 아가들 // super(); // System.out.println("pm01 클래스 생성자"); // } void func01(){ System.out.println("Pm01 class func01() call"); } } public class Ex01 { public static void main(String[] args) throws Exception { //Object Object obj = new Object(); Pm01 pm01 = new Pm01(); System.out.println(pm01.toString()); System.out.println(pm01); System.out.println("pm01클래스의 해시코드: "+pm01.hashCode()); System.out.println("pm01클래스의 경로: "+pm01.getClass()); pm01.func01(); System.out.println("------------------------"); //리플렉션 Class info = Class.forName("com.hb.pm.Pm01"); Object obj2 = info.newInstance(); Pm01 pm02 = (Pm01)obj2; System.out.println(pm02.getClass()); pm02.func01(); }//main end }//class end | cs |
결과