12345678910111213141516171819202122232425 |
- package J20250714.demo03;
- /**
- * @author WanJl
- * @version 1.0
- * @title TestPerson
- * @description
- * @create 2025/7/14
- */
- public class TestPerson {
- public static void main(String[] args) {
- //创建Person的对象
- //Java中的引用数据类型变量,默认值都是null空。
- Person p=null;//创建一个Person类型的变量p
- p=new Person(); //为变量p赋值,赋值的是创建的Person对象
- //创建对象其实是调用了Person类的构造方法来实现的。
- System.out.println(p);
- System.out.println(new Person());
- System.out.println(new Person());
- System.out.println(new Person());
- System.out.println(new Person());
- }
- }
|