Java:JButton的ActionPerform错误

时间:2017-05-18 05:26:52

标签: java swing jframe jbutton

我是java的新手,当用户点击按钮时,我试图从数组中获取最小数字,但它给了我错误。请帮忙:

private void minActionPerformed(java.awt.event.ActionEvent evt) {                                    
        String[] strArray = input.getText().split(",");
        int[] intArray = new int[strArray.length];
        for(int i = 0; i <= intArray.length; i++){
            intArray[i] = Integer.parseInt(strArray[i]);
        }
        Arrays.sort(intArray);
       // System.out.println("min value: "+ intArray[0]);
       output.append("min = "+intArray[0]);

    }

错误是:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3
    at lab10.Lab10.minActionPerformed(Lab10.java:130) 

0 个答案:

没有答案