Inflearn Community Q&A
new 와 constructor.newInstance();의 차이
Written on
·
656
0
Class<?> bookClass = Class.forName("thejava.reflection.MyBook");
Constructor<?> constructor = bookClass.getConstructor(null);//인자 없는 생성자를 넘겨받아서
MyBook book = (MyBook) constructor.newInstance();
이렇게 인스턴스를 생성하는것과
new MyBook()이랑은 무슨차이죠?
둘다 출력해보면
thejava.reflection.MyBook@~ 로 나오는데.. 같은건가요?
javaspringJPA
Answer
This question is waiting for answers
Be the first to answer!





