遇到一个编译错误,麻烦大家帮我看下,谢谢
遇到一个编译错误,我都看了好多次,大小写啊什么的都没有错误,最后实在是找不到错在哪儿了所以来请教各位大哥,谢谢!下面是代码:
class BirthDate {
private int day;
private int month;
private int year;
public BirthDate(int d, int m, int y){
day = d;
month = m;
year = y;
}
public void setDay(int d){
day = d;
}
public void setMonth(int m){
month = m;
}
public void setYear(int y){
year = y;
}
public int getDay(){
return day;
}
public int getMonth(){
return month;
}
public int getYear(){
return year;
}
public void display(){
System.out.println
(day + "-" + month + "-" + year);
}
}
public class Test3{
public static void main(String args[]){
Test test = new Test();
int date = 9;
BirthDate d1 = new BirthDate(7,7,1970);
BirthDate d2 = new BirthDate(1,1,2000);
test.change1(date);
test.change2(d1);
test.change3(d2);
System.out.println("date=" + date);
d1.display();
d2.display();
}
public void change1(int i) {
i = 1234;
}
public void change2(BirthDate b) {
b = new BirthDate(22,4,2004);
}
public void change3(BirthDate b) {
b.setDay(22);
}
}
------解决方案--------------------额 错的很明显啊 哪里有Test类啊 是Test3啊Test test = new Test();
改成Test3 test = new Test3();
------解决方案--------------------看楼主的代码貌似下面这句:
Test test = new Test(); 改成 Test3 test = new Test3();试试