WON.dev
chapter01 : Object 본문
package org.joonzis.ex;
class Sample{
@Override
public String toString() {
return "SAMPLE";
}
}
public class Ex01_Object {
public static void main(String[] args) {
Object object = new Object();
System.out.println(object);
object = 10;
System.out.println(object);
object = "Hello";
System.out.println(object);
// Object object = new Sample(); // 업캐스팅
object = new Sample();
// 객체만 출력 하더라도 자동으로 toString() 이 반환
System.out.println(object.toString());
System.out.println(object);
}
}
'JAVA > chapter20_api' 카테고리의 다른 글
chapter06 : StringBuffer (0) | 2023.05.30 |
---|---|
chapter05 : String (0) | 2023.05.30 |
chapter04 : System (0) | 2023.05.30 |
chapter03 : Object_clone (0) | 2023.05.30 |
chapter02 : Object_equals (0) | 2023.05.30 |