내가 생성자 대신Java : 생성자 내부 또는 외부에서 개체를 초기화 중입니까?
public class HTMLTable {
int value1;
Scanner user_input;
public HTMLTable() {
user_input = new Scanner(System.in);
value = user_input.next();
}
}
내부 또는 외부 객체를 초기화하는 사이에 어떤 차이가 있는지 이해에 관심이 :
public class HTMLTable {
int value1;
Scanner user_input = new Scanner(System.in);
public HTMLTable() {
value = user_input.next();
}
}
누군가가 설명 할 수는?
그리고 http://stackoverflow.com/questions/3918578/should-i-initialize-variable-within-constructor-or-outside-constructor –