1
您好以下程序有什麼問題?因爲我希望它顯示用戶輸入的整數值範圍爲1-10, 11-20,21-30 ... 191-200
?java顯示輸入範圍
public class Program
{
/**
* This is the main entry point for the application
*/
public static void main(String args[])
{
int a[] = new int[100];
int i = 0;
Scanner in = new Scanner(System.in);
while(i<100)
{
System.out.println("Enter a int");
a[i] = in.nextInt();
displayStatistics(a[i]);
}
}
public static void displayStatistics(integer[] a[i])
{
if(a[i]>=1 && a[i]<=100)
{
i++;
System.out.println(); ----> need to display in range 1-10, 11-20,21-30 ... 191-200
} else {
System.out.println("Integer not in range of 1-200");
}
}
}
您正在將'int'值傳遞給displayStatistics。但方法簽名說,輸入將是整數數組。 –
「有什麼問題?」的簡單答案問題是你的代碼甚至沒有試圖做你說的需要做的事情。 – NPE