how to take values from two lists and place a comma between them?

Example:

list1 : apple,mango,grapes

list2: orange,gauva,cherry

I want the out to be :

apple,orange

mango,gauva

grapes,cherry.

And should be able to display the above output in the form of link on jsp.Please help me out for this .

Answers


there are many approaches to do this:

here is one:

If both list are the same size:

final List<String> l1 = new ArrayList<String>();
final List<String> l2 = new ArrayList<String>();
l1.add("mango");
l1.add("apple");
l1.add("grappes");

l2.add("orange");
l2.add("guava");
l2.add("cherry");

for (int i = 0; i < l1.size(); i++) {
    System.out.println(l1.get(i) + "," + l2.get(i));
}

this will print:

mango,orange

apple,guava

grappes,cherry


Need Your Help

how to reset the view position to origin after scale

ios cocoa-touch ios5 ios6

There's two views in my app, viewA(green) and subviewB(red). The initial state of my app is as following:

How to implement setOnScrollListener in RecyclerView

java android-cardview android-recyclerview onscrolllistener endlessscroll

How Do I show progress bar at bottom when user reached to items those are visible in a list.