封装类-student
1 package com.hanqi.z1p1; 2 3 public class Student { 4 5 int StuNo; 6 String Name; 7 int Age; 8 9 Student(int StuNo,String Name,int Age) 10 { 11 this.StuNo=StuNo; 12 this.Name=Name; 13 this.Age=Age; 14 15 } 16 17 void outPut() 18 { 19 System.out.println("学号:"+StuNo+",姓名:"+Name+",年龄:"+Age); 20 } 21 22 23 24 25 26 public static void main(String[] args) { 27 // TODO 自动生成的方法存根 28 29 Student st1=new Student(1001,"张三",22); 30 st1.outPut(); 31 32 Student st2=new Student(1002,"李四",25); 33 st2.outPut(); 34 35 Student st3=new Student(1003,"赵六",24); 36 st3.outPut(); 37 38 39 40 41 42 } 43 44 }
运行结果: