자바 클래스 선언 오류
322
보니베어
작성한 질문수 1
0
public class EE {
int a = 1;
EE ee = new EE();
ee.a = 2;
}
이렇게하면 오류가 나고
여기서 블록을 하나 더 감싸면 오류가 안나더라구요
public class EE {
int a = 1;
EE ee = new EE();
{ ee.a = 2 };
}
무슨 이유에서일까요?
클래스 선언 블록에서는 무언가 동작을 하는 코드를 넣을수 없는건가요?
답변 1
0
Well, here is the simple example how to declare class in Java.
public class Person { // Class members (fields, methods, constructors, etc.) go here // Example field (instance variable) private String name; // Example constructor public Person(String name) { this.name = name; } // Example method public void sayHello() { System.out.println("Hello, my name is " + name); }}Thanks
17강 강의에 목데이터 첨부파일이 없습니다.
2
30
2
Jib 이미지 빌드에서 docker credential 관련으로 이슈가 있다면
1
76
2
아무도 모르게 책 내시면 모르실 줄 알고!!
1
52
2
6:13 부근에서 끝나버립니다 그 다음 진행부터는 다음 진행창이 나오지 않아요
1
57
6





