wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes find method to search an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "find method to search an array" Watch "find method to search an array" New topic

find method to search an array

John Althoff

Joined: Sep 11, 2002
Posts: 2
I am trying to search an array with a string. I was told their was a class method called find that would return the index of the matching string contained in an array of stringBuffer objects, but I don't know what class it is a method of. I was told that it would accept an array of stringBuffer object references and a string to find. Maybe I am just trying to call the method wrong. This is what I have now.
The array already exists.

int itemIndex;
itemIndex = find(items, item);
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Take a look at
followed by
Arrays.binarySearch(Object[]�a, Object�key)
But if you are going to do this often, you should use a Set, not an array.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
It is sorta covered in the JavaRanch Style Guide.
subject: find method to search an array
Similar Threads
class method containg find
background on array length
equals() in StringBuffer
Arraylist with Objects
Performance between Array list and StringBuffer to store Large amount of data?