初识面向对象
作者:互联网
package src.com.qiqi.oop;
public class Student {
//属性:字段
String name;
int age;
public void study(){
System.out.println(this.name + "在学习");
}
}
/*
//一个项目 应该只存在一个main方法
public static void main(String[] args) {
//类 抽象的
Student guai = new Student();
Student hong = new Student();
guai.name = "怪!";
hong.name = "红!";
guai.age = 7;
hong.age = 7;
System.out.println("guai的名字是:" + guai.name);
System.out.println("hong的名字是:" + hong.name);
System.out.println("guai的年龄是:" + guai.age);
System.out.println("hong的年龄是:" + hong.age);
}
*/
标签:hong,name,System,guai,面向对象,初识,Student,out 来源: https://www.cnblogs.com/shuqiqi/p/16452561.html