-2
這是我到目前爲止已經試過代碼:如何創建一個從用戶讀取數字並在數組中搜索該數字的Java程序?
int num;
int[] a={2, 3, 4,7, 9};
System.out.println("enter a no");
for(int i=0; i<a.length; i++){
num= in.nextInt();
if(num==a[i])
看到這個問題。 http://stackoverflow.com/a/1128728/1150683另外,在循環之前將輸入分配給變量。 –