[英]for loop - test counter - why it is used less than
對於“測試計數器”中的for循環,我感到困惑,為什么它的使用量少於(jerry <tom.length)..?
public static void main (String args[]) {
int tom[] = {1, 2, 3, 4, 5};
for (int jerry=0; jerry<tom.length; jerry++)
{
System.out.println(jerry+ "\t" +tom[jerry]);
} }
java(c / c ++ / ruby等)中的數組從0而不是1開始索引數組。
這就是為什么它以jerry = 0(第一個索引為0)開始並在數組的長度-1(即您的示例中,最后一個索引為4)的長度處結束的原因
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.