public static void loop_array_build1()
{
int array_quantity = 12;
int rd_1[] = new int[array_quantity];
//Building
for (int i = 1; i < array_quantity; i++)
{
rd_1[i] = i;
System.out.println("Array building : " + rd_1[i]);
}
System.out.println("");
System.out.println("Total array built -> " + rd_1.length);
System.out.println("");
//Showing
for (int x = 1; x <= rd_1.length; x++)
{
System.out.println("Array showing : " + x);
}
}
我不能使用小於和等於(= <),因爲我想從1到建立直到12,但如果我使用比(<)
偏少它不是錯誤如何使用小於和等於用於循環在Java來構建陣列for(int i = 1; i < array_quantity; i++) << Not error for(int i = 1; i <= array_quantity; i++) << Error
,或者有在0只能從1開始的數組索引,不是?
當我打印該行
System.out.println("Total array built -> " + rd_1.length);
它顯示陣列有12個,
也許它從這些2線取決於int array_quantity = 12; int rd_1[] = new int[array_quantity];
我怎麼能真正知道量陣列已經建立,而不是從索引。在Java中
我不清楚你問什麼... –