반응형 String1 자바 객체지향 문법 - final, String, 접근제한자, 인터페이스 부모가 될 수 없는 클래스 - 상속을 금지 시키려면 클래스를 정의할 때 final 키워드를 사용한다. - public fianl class 클래스명 {} String 클래스는 왜 final 일까? - 다음 예제를 보며 알아보자 String str1 = "hello";String str2 = "hello";String str3 = new String("hello");String str4 = new String("hello"); 다음과 같은 코드에서 str1,2,3,4를 출력한다면?답 : hellohellohellohello가 나오게 됨 만약 if(str1 == str2){}if(str1 == str3){}if(str3 == str4){}이경우에는 첫번째 if문만 참이된다.이유는 참조변수와 메모리에 어떻게.. 2023. 2. 16. 이전 1 다음 반응형