/If the for loop goes to i< numbers.length then how would it ever end up at i == numbers.length? Wouldn't it stop iterating at numbers.length-1?/
class Phone {
public static void main(String args[]){
String numbers[][] = {
{"Tom", "535-5334"},
{"Bill", "432-5432"}
};
int i;
if(args.length != 1)
System.out.println("Usage: java Phone <name>");
else {
for(i=0; i<numbers.length; i++) {
if(numbers[i][0].equals(args[0])){
System.out.println(numbers [i] [0] + ":" + numbers [i][1]);
break;
}
}
if(i == numbers.length)
System.out.println("name not found");
}
}
}
This example is in my introductory java book and I don't understand it. It would make sense to me if the for loop used i<=numbers.length