public class Set {
private int[] num;
public Set(int ... nums){
this.num = nums;
}
public int getSet(){
for (int results : this.num){
return results;
}
}
}
的阵列我写了这个类作为一个测试,看看使用的方法尝试和输出的整数数组,但我有麻烦1.4.3整数
这里是驱动程序:
public class SetTest {
public static void main(String[] args) {
Set set = new Set();
set.Set(1,2,3);
set.getSet();
}
}
我难倒做什么,我得到这个错误也“的方法IntegerSet(INT,INT,INT)是未定义的类型设置”
'IntegerSet'在哪里?并且不要使用预定义的类或接口名称命名您的类。 – 2013-02-14 08:44:43
您有一个名为'Set'的类,然后尝试从'IntegerSet'类中创建一个实例。什么是IntegerSet?在getSet方法中,你有一个for循环试图返回每一个整数。这不会像你想象的那样工作。它将只返回第一个整数。它将进入循环并返回调用方法的第一个整数。返回后没有其他任何东西被执行。没有更多的循环 – pbaris 2013-02-14 08:51:14
你得到正确的错误。你在哪里定义了IntegerSet(int,int,int)方法? – 2013-02-14 08:54:42