Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...