서로 다른 시그니처를 갖는 여러 메소드를 한 클래스 내에 같은 이름으로 정의하는 것
- println()
- println(boolean x)
- println(char x)
- println(char[] x)
- println(double x)
- println(float x)
- println(int x)
- println(long x)
- println(Object x)
- println(String x)
① 자기 자신의 메모리를 가르킨다.
② 생성자에서 다른 생성자를 호출할 경우 사용한다.
③ 인스턴스 자신의 주소를 반환할 때 사용한다.
- 인스턴스 자기 자신을 가리키는 키워드
- this 는 클래스를 기반으로 생성된 인스턴스를 가리키는 참조
String str1 = new String("Simple String");
String str2 = "The Best String";
String str1 = "Simple String";
String str2 = "Simple String";
String str3 = new String("Simple String");
String str4 = new String("Simple String");
if(str1 == str2)
System.out.println("str1과 str2는 동일 인스턴스 참조");
else
System.out.println("str1과 str2는 다른 인스턴스 참조");
if(str3 == str4)
System.out.println("str3과 str4는 동일 인스턴스 참조");
else
System.out.println("str3과 str4는 다른 인스턴스 참조");
✅예측 결과
str1과 str2는 동일 인스턴스 참조
str3과 str4는 다른 인스턴스 참조
✅이유
str1과 str2 "Simple String" 으로 같은 주소에 할당되어 같으며
str3과 str4는 각기 다른 주소에 할당되어서 다르다.
객체가 최초 생성된 시점 이후 상태 값이 변하지 않는 객체
참고) charAt 함수
입력하시오. hello
출력)
총 글자 수는 5개 입니다.
모음은 : 2개 입니다.
자음은 : 3개 입니다.
참고) charAt 함수
입력:abcde
출력:edcba