File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes index of an element in an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "index of an element in an array" Watch "index of an element in an array" New topic
Author

index of an element in an array

krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
good day,
hw to find the index of an element in an array.


have a great day,
krishna prasad
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

java.util.List has an indexOf method (providing your equals method is implemented correctly), and can convert from an Array to a List using java.util.Arrays.asList
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Well, if the elements of the array are sorted, then you could use the java.util.Arrays class. Otherwise, I believe you have to loop through the array to find the element that you want.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: index of an element in an array