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+"年龄bai为:"+age+"学号为du:zhi"+id); } }
public class test{ public static void main(String args[]){ student stu = new student(); stu.name=张三dao; 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()); } }