类与对象的创建

类与对象的创建

  • public class Application {
        //一个项目只有一个main方法
        public static void main(String[] args) {
    
            //类:抽象化、实例化
            //实例化后产生一个对象
            Student stu1 = new Student();
            Student stu2 = new Student();
            stu1.name = "张三";
            System.out.println(stu1.name);
            stu1.study();
            System.out.println(stu2.name);
        }
    }
    
    //学生类
    public class Application {
        //一个项目只有一个main方法
        public static void main(String[] args) {
    
            //类:抽象化、实例化
            //实例化后产生一个对象
            Student stu1 = new Student();
            Student stu2 = new Student();
            stu1.name = "张三";
            System.out.println(stu1.name);
            stu1.study();
            System.out.println(stu2.name);
        }
    }
    
    //张三
    张三is studying!
    null
    
posted @ 2021-04-09 09:26  saxon宋  阅读(42)  评论(0)    收藏  举报