如何修复线程“ main”中的异常java.lang.UnsupportedOperationException:stocks(int input1,int [] input2)

时间:2019-07-24 17:03:22

标签: java

任何人都可以让我知道PFA代码的原因-

package stockprice;

import java.util.Scanner;

public class UserMainCode {

    public int stocks(int input1, int[] input2) {

        int temp = input2[0];

        for (int i = 0; i < input2.length - 1; i++) {
            for (int j = i+1; j < input2.length - 1; j++) {
                if(temp<input2[j]) {
                    System.out.println(temp);
                }else {
                    temp=temp+input2[j];
                }
            }
        }
        throw new UnsupportedOperationException("stocks(int input1, int[] input2)");
    }


    public static void main(String[] args) {
        UserMainCode obMainCode = new UserMainCode();
        Scanner inScanner = new Scanner(System.in);
        int input1 = inScanner.nextInt();
        int input2[] ;
        input2 = new int[input1];
        for (int i = 0; i <= input2.length - 1; i++) {
            input2[i]=inScanner.nextInt();
        }
        obMainCode.stocks(input1, input2);
    }
}

0 个答案:

没有答案