Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter01 : Object 본문

JAVA/chapter20_api

chapter01 : Object

GAWON 2023. 5. 30. 18:17
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