Suppose I have a custom object set up in a class similar to this.
public class anObject {
public String id, otherProperty;
public anObject(){
this.id = "1";
this.otherProperty = "cat";
}
}
Then I create an array of these objects in another class
anObject[] objects = new anObject[40];
for(int i=0; i < 40; i++){
objects[i] = new anObject();
}
What can I do then to find the first object in the array that has an id of 2 (for example)?
Or am I missing something?
EDIT: added the
break. Also, there is a convention that class names begin with an uppercase letter, such asAnObject.