呵呵,看看后面的注释 count = getCount(); // a method defined in the program 估计只是一个说明性的例程而已,当然无法运行 注意E文水平也要提高啊
public class nihao{ public static void main(String args[]){ int count; GetCnt getCnt = new GetCnt(); //new object count = getCnt.getcount(); // a method defined in the GetCnt if (count < 0) { System.out.println("Error: count value is negative."); } else { System.out.println("There will be " + count + " people for lunch today."); } } }class GetCnt { private int other_count = 8;
int getcount() { return other_count; } };
是类class GetCnt里的方法 他的作用是返回一个值另外我觉得楼主一开始的父类应该是这样的吧 public class Nihao
public class nihao{ public static void main(String args[]){ int count; count = getCount(); // a method defined in the program if (count < 0) { System.out.println("Error: count value is negative."); } else { System.out.println("There will be " + count + " people for lunch today."); } }/** * @return */ private static int getCount() { return 0; } }
count = getCount(); // a method defined in the program
估计只是一个说明性的例程而已,当然无法运行
注意E文水平也要提高啊
public static void main(String args[]){
int count;
GetCnt getCnt = new GetCnt(); //new object
count = getCnt.getcount(); // a method defined in the GetCnt
if (count < 0) {
System.out.println("Error: count value is negative.");
} else {
System.out.println("There will be " + count +
" people for lunch today.");
}
}
}class GetCnt
{
private int other_count = 8;
int getcount()
{
return other_count;
}
};
他的作用是返回一个值另外我觉得楼主一开始的父类应该是这样的吧
public class Nihao
public static void main(String args[]){
int count;
count = getCount(); // a method defined in the program
if (count < 0) {
System.out.println("Error: count value is negative.");
} else {
System.out.println("There will be " + count +
" people for lunch today.");
}
}/**
* @return
*/
private static int getCount() {
return 0;
}
}