javaSE-day01-Object概述

This commit is contained in:
2026-05-30 14:48:17 +08:00
parent c4394dc6b5
commit 2d28aa4c3e
3 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package com.inmind.object01;
/*
Object:是所有类的父类,java中所有的类直接或者间接继承自Object
*/
public class Demo01 {
public static void main(String[] args) {
//普通创建对象
Person p = new Person();
Student s = new Student();
//多态创建对象
Person p1 = new Student();
}
}

View File

@@ -0,0 +1,4 @@
package com.inmind.object01;
public class Person {//直接继承自Object
}

View File

@@ -0,0 +1,4 @@
package com.inmind.object01;
public class Student extends Person{//间接继承自Object
}