类与对象的创建
类与对象的创建
public class application {
public static void main(String[] args) {
student xm = new student();
student xy = new student();
xm.name ="xiaoming";
xm.age = 11;
System.out.println(xm.name);
System.out.println(xm.age);
xm.study(xm);
System.out.println(xy.name);
System.out.println(xy.age);
xy.study(xy);
}
}
//学生类
public class student {
String name;
int age;
public void study(student s1){
System.out.println(s1.name + "正在学习");
}
}