public static int[] allBetween()
{
Scanner input = new Scanner(System.in);
int first;
int last;
System.out.println("Enter the first number");
first = input.nextInt();
System.out.println("Enter the last number");
last = input.nextInt();
int[] between = {((last - first) + 1)};
for(int count = 0; count <= (last - first); count++)
{
between[count] = (first + count);
}
return between;
}
私は少し錆びており、ここでは問題が見られません。配列のサイズを手動で 100 に割り当て、最初と最後を 1 と 5 に割り当てようとしましたが、それでも同じエラーが返されます。
何か案は?
これは、スタック オーバー フローに関する私の最初の投稿です。間違った方法で投稿している場合は、修正してください