File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion 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)
I agree. Here's the link:
subject: find method to search an array
It's not a secret anymore!