Object
✅ Java.lang 패키지
Java.lang안에 이런 클래스들이 내장되어 있다.
- Object Class
- System:
System.out.println()
- String
- Wrapper: 기본 타입의 데이터를 갖는 객체 만들 때 사용
- Math
우리가 가져오지 않아도 자동으로 가져와져서 쓰여짐
✅ 최상위 클래스 Object
JAVA의 최상위 클래스
모든 클래스의 상위 클래스
1
2
3
4
5
6
7
public class Animal extends Object
//사실은 우리도 모르게 모든 class는 Object를 상속함
//extends Object뒤에 붙여져 있음, 생략되어 있지만~
//당연히 upcasting도 가능함
Animal animal1 = new Animal("cat");
Object animal2 = new Animal("dog");
✅ Object method
toString()
hashCode()
wait()
- when calling thread has intrinsic lock
- make current thread wait
notify()
- when calling thread has intrinsic lock
- wake up thread
notifyAll()
- when calling thread has intrinsic lock
- wake up all the threads()
This post is licensed under CC BY 4.0 by the author.