Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array output

 
Shamsul Kamal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic