新学的面向对象,虽然很简陋,但是还是有点迷糊

 1 public class Student {
 2     String name;
 3     String id;
 4     int age;
 5     
 6     public void zhuTou() {
 7         System.out.println("你是个猪头!");
 8     }
 9     public void shaZi() {
10         System.out.println("你是个*");
11     }
12     
13 
14 }
 1 public class Draft04 {
 2     public static void main(String[] args) {
 3         Student s=new Student();
 4         s.name="猪头";
 5         s.id="123456";
 6         s.age=18;
 7         Student s2=new Student();
 8         s2.age=20;
 9         s2=s;
10         System.out.println(s.age);
11         s.zhuTou();
12     }
13 }

 

上一篇:Java转义字符


下一篇:电商店铺首页设计思路和过程经验分享