File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array problem

 
peterx peter
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand your question. Do you want to do that with the existing method or add an extra method?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code isn't quite what you're looking for, but it should give you an idea of how you might approach this problem.

You could adapt the method to take two arguments: The number you want to match, and which match you want (1st, 2nd, 3rd, etc.).

The method could have a variable to count the number of matches. Then when you find a match and the count is where you want it, return that index. Otherwise, return -1 to indicate that it wasn't found.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic