This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array problem" Watch "Array problem" New topic
Author

Array problem

peterx peter
Greenhorn

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

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

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
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array problem
 
Similar Threads
strange behaviour of reference variable when passing to a function
Confusion about program output!!!
doubt in invoking a instance variable using ref. variable
code not understood
please explain