Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)

Here are the conditions: do not modify the original lists; JDK only, no external libraries.one-liner or a JDK 1.3 version is preferred. 

Is there a simpler way than:

List<String> newList = new ArrayList<String>();

newList.addAll(listOne);

newList.addAll(listTwo);

1 Answer

0 votes
by (46k points)

Here's one linear which fulfills all the conditions mentioned by you:

List<String> newList = new ArrayList<String>(listOne);

newList.addAll(listTwo);

click here to read more about it.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...