Student類:
package com.bao;
public class Student {
int stuNo;String name,sex;int age,weight;
Student(int s,String n,String se,int a,int w)
{
stuNo=s;name=n;sex=se;
age=a;weight=w;
}
void outPut()
{
System.out.println("學號:"+stuNo);
System.out.println("姓名:"+name);
System.out.println("年齡:"+age);
System.out.println("體重:"+weight);
System.out.println("性別:"+sex);
}
}
主類TestClass
package com.bao;
public class TestClass {
public static void main(String[] args) {
Student stu=new Student(20160000,"王寶強",男,30,70);
Student stu=new Student(201615,"宋喆",男,25,70)
}
}
運行結果
學號:20160000
姓名:王寶強
年齡:30
體重:70
身高:170
性別:男
學號:201615
姓名:宋喆
年齡:25
體重:70
性別:男