aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "find method to search an array" Watch "find method to search an array" New topic
Author

find method to search an array

John Althoff
Greenhorn

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);
break;
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Take a look at
Arrays.sort(Object[])
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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: find method to search an array
 
Similar Threads
class method containg find
background on array length
Arraylist with Objects
Performance between Array list and StringBuffer to store Large amount of data?
equals() in StringBuffer