public class Demo {
public String name;
public String brithday;
public int number;
public void setName(String name){
this.name=name;
}
public void setBrithday(String brithday){
this.brithday=brithday;
}
public void setNumber(int number){
this.number=number;
}
public String getName(){
return this.name;
}
public String getBrithday(){
return this.brithday;
}
public int getNumber(){
return this.number;
}
public static void main(String[]args){
Demo student=new Demo();
student.setName("杨");
student.setBrithday("1996-11-11");
student.setNumber("1408441063"); //这里报错
System.out.println(student.getName());
System.out.println(student.getBrithday());
System.out.println(student.getNumber());
}
}
你的setNumber(int number)传入的参数是需要int类型的,student.setNumber("1408441063");传入的类型是字符串所以报错,要保证传入的类型和要和参数的类型一致