- #1
stripes
- 266
- 0
Homework Statement
If I am given a regular, single dimensional array in Java, how do I search for an element in it, and then how do I get the index of that element?
I have been trying:
Code:
int largest; //some number that has been predetermined in earlier code
int index3 = data.indexOf(largest);
But it keeps giving me errors in compiling. This method doesn't exist or something. I've read online and indexOf is very confusing. Not sure why I can't simply look up the format of it. I always figured it was
Code:
int number = stringName.indexOf(whatyou'researchingfor);
and then I can use 'number' later on as the index at which 'whatyou'researchingfor' showed up.