学生信息(题)

 1 public class Student
 2 {
 3     int xuehao;
 4     String xingming;
 5     int nianling;
 6     
 7     Student (int xuehao,String xingming,int nianling)
 8     {
 9         this.xuehao=xuehao;
10         this.xingming=xingming;
11         this.nianling=nianling;
12     }
13     
14     void getoutPut()
15     {
16         
17         System.out.println("学号是:"+this.xuehao);
18         System.out.println("姓名是:"+this.xingming);
19         System.out.println("年龄是:"+nianling+"岁");
20         System.out.println();
21         return;            
22     }
23     
24     public static void main(String[] args)
25     {
26         Student xuesheng1=new Student(123456,"小明",18);
27         xuesheng1.getoutPut();
28         
29         Student xuesheng2=new Student(123546,"小红",19);
30         xuesheng2.getoutPut();
31         
32         Student xuesheng3=new Student(124356,"小亮",20);
33         xuesheng3.getoutPut();
34         
35         Student xuesheng4=new Student(132546,"小明",21);
36         xuesheng4.getoutPut();
37     }
38 }
39 /*
40 题目  编写Java应用程序。首先,定义描述学生的类——Student,包括学号(int)、
41 姓名(String)、年龄(int)等属性;二个方法:Student(int stuNo,String name,int age)
42 用于对对象的初始化,outPut()用于输出学生信息。其次,再定义一个主类——
43 TestClass,在主类的main方法中创建多个Student类的对象,使用这些对象来测
44 试Student类的功能。
45 */

 

posted @ 2016-05-17 22:43  明天会更好!!!!  阅读(125)  评论(0)    收藏  举报