s-day01-Object概述

This commit is contained in:
2026-07-28 14:42:25 +08:00
parent ff8c0840aa
commit 79ad38dcc6
3 changed files with 31 additions and 0 deletions
@@ -0,0 +1,23 @@
package com.inmind.object01;
/*
Object类:所有类的父类【祖宗类】,java中所有的类直接或者间接继承自Object
*/
public class Demo01 {
public static void main(String[] args) {
Person p = new Person();
Student s = new Student();
//Object类的多态
Object o1 = p;
Object o2 = new Person();
Object o3 = new Student();
//Object是可以接受任意引用数据类型!!!!!
Object o4 = "123";
method(p);
method(s);
method("abc");
}
public static Object method(Object o) {
return null;
}
}
@@ -0,0 +1,4 @@
package com.inmind.object01;
//直接继承Object类
public class Person extends Object{
}
@@ -0,0 +1,4 @@
package com.inmind.object01;
//间接继承Object类
public class Student extends Person{
}