我得到我的程序的誤差範圍的異常是什麼意思?處理出陣列
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at MultiCharacterDisplay.main(MultiCharacterDisplay.java:74)
Java Result: 1
這是後我運行它,我得到一個出界外的我已經得到了從
public void setText(String text) {
if (text.length() > segmentDisplayCount) {
text = text.substring(0, segmentDisplayCount);
}
int i = 0;
for (char c: text.toCharArray()) {
segmentDisplays.get(i++).setCharacter(c);
}
}
public static void main(String[] args) {
String text = args[1];
MultiCharacterDisplay display = new MultiCharacterDisplay(text.length(), Color.GREEN);
display.setText(text);
JFrame frame = new JFrame();
frame.setBackground(Color.black);
frame.getContentPane().setBackground(Color.black);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(display);
frame.pack();
frame.setVisible(true);
}
錯誤的代碼,因爲這一點我不知道,爲什麼,有人可以向我解釋嗎?
爲什麼你跳過'ARGS [0]'?嘗試'的System.out.println(Arrays.toString(參數));' –
喜,它甚至沒有任何東西打印出來 – Reynolds
嘗試用命令行參數運行程序。你顯然不是。 –