public class student{
private String name;
private int age;
private int id;
public void stuInfo(String name,int age,int id){
System.out.println("名字为:"+name+"年龄为:"+age+"学号为:"+id);
}
}
public class test{
public static void main(String args[]){
student stu = new student();
stu.name=张三;
stu.age=16;
stu.id=45;
stu.stuInfo(name,age,id);
}
}
public class Student {
private String name;
private int age;
private String id;
public Student(String name,int age,String id){
this.name=name;
this.age=age;
this.id=id;
}
public String info(){
return "name="+name+",age="+age+",id="+id;
}
public static void main(String[] args){
System.out.println(new Student("Sam",30,"10010").info());
}
}