新学的面向对象,虽然很简陋,但是还是有点迷糊
作者:互联网
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 }
标签:s2,age,迷糊,System,面向对象,新学,Student,public,out 来源: https://www.cnblogs.com/fjyyyy/p/15933633.html