/*package gl;
//建立学生类xs
class xs{
//数据成员变量
int xh;
String xm;
String xb;
int nl;
//成员方法
public void showxs() {
System.out.println("学号:"+xh);
System.out.println("姓名:"+xm);
System.out.println("性别:"+xb);
System.out.println("年龄:"+nl);
}
}
public class gl {
public static void main(String[] args) {
// TODO Auto-generated method stub
//成员赋值
xs xs1= new xs();
xs1.xh=119509228;
xs1.xm="周月";
xs1.xb="女";
xs1.nl=19;
xs1.showxs();
}
}*/
//构造方法,一次性输入
package gl;
//建立学生类xs
class xs{
//数据成员变量
int xh;
String xm;
String xb;
int nl;
xs(int xh1,String xm1,String xb1,int nl1){
xh=xh1;
xm=xm1;
xb=xb1;
nl=nl1;
}
//成员方法
public void showxs() {
System.out.println("学号:"+xh);
System.out.println("姓名:"+xm);
System.out.println("性别:"+xb);
System.out.println("年龄:"+nl);
}
}
public class gl {
public static void main(String[] args) {
// TODO Auto-generated method stub
//成员赋值
xs xs2 = new xs(119509228,"周月","女",19);
xs2.showxs();
}
}