The array: array contains only Test2 objects. It does not contain either int or String objects.
You must ask the Test2 object what it contains. Add methods to the Test2 class that will check for the contents that you want to test for. Then you can call those methods to determine the contents of a Test2 object.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
You can do the search in a for loop in any method that has access to the array.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Sure. Suppose I had an array of Car objects, I could find the Fords with something like
for (Car c : myArrayOfCars) {
if (c.getManufacturer().equals("Ford") ...
}
JamesCherrill
... trying to help
8,533 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
Question Answered as of 1 Year Ago by
NormR1
and
JamesCherrill