int x;이 예제에서 변수 x는 기본적으로 0으로 설정되고 두 번째 줄인 값 5는 x가 가리키는 메모리 위치에 기록됩니다. Java는 프로그래머가 메모리 상자를 조작하는 것을 금지하고 메모리 위치가 아닌 객체의 메소드에만 액세스 할 수 있습니다.
x = 5;
Point dot = null;
dot.getX()를 호출합니다.
스레드 "main"의 예외 java.lang.NullPointerException2) null 객체의 인스턴스에 액세스하거나 수정합니다.
at Test.main(Test.java:27)
점 점 = null;
dot.getX()를 호출합니다.
스레드 "main"의 예외 java.lang.NullPointerException3) throw null
at Test.main(Test.java:38)
IOException nullException = null;
try {
nullException throw;
} catch (IOException e) {
e.printStackTrace();
}
char[] ch = null;5) array
int 길이 = ch.length;
char[] ch = null;
char c = 채널[0];
Thread th=null;
synchronized(th){
System.out.print("이 스레드는 동기화되었습니다.");
}
void display(String phrase){이 솔루션은 객체가 null이므로 display() 프로시저에서 아무 일도 일어나지 않기 때문에 경우에 따라 최적이 아닙니다.
//문장이 null이 아닌지 확인
if(phrase!=null)
System.out.print(phrase);
}
String string="";
//Declaration
Thread[] th=new Thread[3];
//초기화
th[0]=new Thread();
th[1]=새 스레드();
th[2]=새 스레드();
Please disable your ad blocker and refresh the window to use this website.