Java 使用多个参数和一个字符串数组调用方法

Java 使用多个参数和一个字符串数组调用方法,java,arrays,Java,Arrays,我必须创建一个程序,要求我使用名为DayPrices的类不断要求搜索日期。我已经完成并计算出了程序的大部分内容,我想当我调用这个函数时,它会工作的 get.Data(String[], double,double,double,double,double,double) I 我在netbeans中得到这个错误,指出应该是“.class” } /** **@作者Emad Khalique */ 公共类CST1201{ public static void main(String[] args)

我必须创建一个程序,要求我使用名为DayPrices的类不断要求搜索日期。我已经完成并计算出了程序的大部分内容,我想当我调用这个函数时,它会工作的

get.Data(String[], double,double,double,double,double,double) I 
我在netbeans中得到这个错误,指出应该是“.class”

}

/** **@作者Emad Khalique */ 公共类CST1201{

public static void main(String[] args){


    DayPrices pricesCall = new DayPrices ();

    int runAgain = 1;
        while(runAgain == 1)  //create a method to increment runAgain variable
        {    
            Scanner input = new Scanner(System.in);
            DayPrices prices = new DayPrices();
            prices.openFile();
            prices.readFile();

            while(runAgain == 1){
            //saidfunction that will get the data    
                prices.getData(String[], double, double, double, double, double, double);

            }

            prices.closeFile();

            System.out.println("Would you like to continue? ");
            runAgain = input.nextInt();

        }    
}

}

我认为您不应该发送“String[]”,因为编译器认为您正在传递类类型,所以您可以简单地在prices.getData()函数中传递“String[]”变量。

您不能使用类型参数调用方法,您需要发送实际值

prices.getData(new String[3], 3.4, 17, 5.5, ...);
如果希望从
readFile()
中获取值,一个选项是将变量移动到类作用域,并创建getter,以便在
main

public class DayPrices {
    private double open;        
    private double high;
    private double low;
    // more variables

    public getOpen() {
        return open;
    }

    // more getters

    public void readFile() {
        open = Double.parseDouble(open1[counter]);        
        high = Double.parseDouble(high1[counter]);
        low = Double.parseDouble(low1[counter]);
        //...
    }
}
prices.getData(prices.getData1(), prices.getOpen(), ...);
main

public class DayPrices {
    private double open;        
    private double high;
    private double low;
    // more variables

    public getOpen() {
        return open;
    }

    // more getters

    public void readFile() {
        open = Double.parseDouble(open1[counter]);        
        high = Double.parseDouble(high1[counter]);
        low = Double.parseDouble(low1[counter]);
        //...
    }
}
prices.getData(prices.getData1(), prices.getOpen(), ...);
作为旁注,Java中的变量应该以小写字母开头