Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Array problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array problem" Watch "Array problem" New topic

Array problem

peterx peter

Joined: Nov 02, 2004
Posts: 19
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
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

Joined: Aug 31, 2004
Posts: 11343

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.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Array problem
It's not a secret anymore!