Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find method to search an array

 
John Althoff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic