我正在嘗試編寫一個非常簡單的程序來接收用戶的輸入并在屏幕上再次打印出來。但我收到錯誤。我的代碼:-import java.util.*;class res_cmd { public static void main(String args[]){ int first; System.out.println("Enter a number"); first = Integer.parseInt(args[0]); System.out.println("The result is"+first); }}我收到的錯誤:-C:\Users\hp\Desktop>java res_cmdEnter a numberException in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at res_cmd.main(res_cmd.java:7)我不確定為什么會收到此錯誤。掃描儀類和 Buffer 方法可以正常工作,但命令行不能。請幫忙。
添加回答
舉報
0/150
提交
取消