This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to do string array searches w/ multiple returns. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to do string array searches w/ multiple returns." Watch "How to do string array searches w/ multiple returns." New topic
Author

How to do string array searches w/ multiple returns.

Fritz Largosa
Ranch Hand

Joined: Sep 12, 2005
Posts: 70
Is there a way to search an array for multiple matches? For example My array will have
"A","AB","AAB","AA123","BC","BA","BA","BAC","C"..."Z". I want a function to be able to return, A, AB,AAB,AA123 if it receives "A", if the function receives AA it returns AAB,AA123. Anyone have any, ideas, links, documentation, which my be helpful? I'm stuck can't seem to find any helpful info for this one.

Thanks.
Adam Nace
Ranch Hand

Joined: Jul 17, 2006
Posts: 117
Basically, you want to return a list. You want something like this:



I leave it to you to define the matches() method.

- Adam
Fritz Largosa
Ranch Hand

Joined: Sep 12, 2005
Posts: 70
Thanks, I'll give this one a try.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to do string array searches w/ multiple returns.
 
Similar Threads
Query Question
recursion....im an idiot!!
What is the use of static block
String combinations & permutations
All possible combinations of the elements in the string array