aspose file tools*
The moose likes Beginning Java and the fly likes Array output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array output" Watch "Array output" New topic
Author

Array output

Shamsul Kamal
Greenhorn

Joined: Dec 05, 2008
Posts: 2
Hi all. I have a problem to print this two array.

String[] a = {"a", "b", "c", "d", "e"};
String[] b = {"b", "d"};

Output:

a
bb
c
dd
e

How to get this output with this arrays. I have try to print this with for loop but it's not working. Anybody can help me.
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
One for loop to iterate over the first array, an inner one to iterate over the second array and an if statement to check if the current object from outer is equal to the one in the inner



<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Array output