wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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>
 
Consider Paul's rocket mass heater.
 
subject: Array output
 
Similar Threads
How to solve this problem
inputstream and outputstreams
Reg. Stream basic question
Logic with java code
Stuck on Homework