基本上,我在一本书中做一个 Java 练习,这个源代码是它对练习的答案。但是,eclipse 说倒数第三行有一个错误,说“- 构造函数 PhoneNumber() 未定义”。但据我了解,该特定构造函数定义正确,那么问题是什么?
public class PhoneNumber {
// Only the relevant source codes are posted here.
// I removed other bits cause I'm sure they are not responsible for the
// error
private char[] country;
private char[] area;
private char[] subscriber;
public PhoneNumber(final String country, final String area, final String subscriber) {
this.country = new char[country.length()];
country.getChars(0, country.length(), this.country, 0);
this.area = new char[area.length()];
area.getChars(0, area.length(), this.area, 0);
this.subscriber = new char[subscriber.length()];
subscriber.getChars(0, subscriber.length(), this.subscriber, 0);
checkCorrectness();
}
private void runTest() {
// method body
}
public static void main(final String[] args) {
(new PhoneNumber()).runTest(); // error here saying :
// "The constructor PhoneNumber() is undefined"
}
}