认真学习qaq
作者:互联网
package lei;
public class Student {
//属性 :字段
String name;//null :抽象不能具体赋值
int age;//0
// 方法
public void study(){
System.out.println(this.name+"在学习");
}
}
package lei;
public class AppLication {
public static void main(String[] args) {
//类:抽象 要示例化
//类实例化以后会返回一个自己的对象!
//student对象就是一个Student类的具体实例!
Student xiaomin = new Student();
Student xiaohong = new Student();
xiaomin.age=4;
xiaomin.name="小明";
System.out.println(xiaomin.name);
System.out.println(xiaomin.age);
xiaomin.study();
}
}
标签:qaq,name,xiaomin,System,Student,认真学习,public,out 来源: https://www.cnblogs.com/zsj519086/p/15034305.html