class Person {
private char[] name = new char[255];
public void setName(char[] value) {
for(int i=0; i < value.length; i++) {
if(name.length >= i) {
throw new ArrayIndexOutOfBounds(..);
}
name[i] = value[i];
}
}
}
This doesn't seem to make sense to me... name.length = 255, when i = 0
or i < 255, the code will throw the ArrayIndexOutOfBounds() exception.
Shouldn't the IF check be the other way around?