By: Editorial Staff | Last Updated: | In: Java Tutorial
In this program, we are going to share Java program to Join Two Lists with the output. If you are a Java beginner and want to start learning the Java programming, then keep your close attention in this tutorial as I am going to share how to write a Java program to Join Two Lists.
Copy the below Java program and execute it with the help of Javac compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import java.util.ArrayList; import java.util.List; import org.apache.commons.collections.ListUtils; public class JoinListsProgram { public static void main(String[] args) { List<String> l1 = new ArrayList<String>(); list1.add("a"); List<String> l2 = new ArrayList<String>(); list2.add("b"); List<String> joined = ListUtils.union(l1, l2); System.out.println("list1: " + l1); System.out.println("list2: " + l2); System.out.println("joined: " + joined); } } |
Liked this program? Do Like & share with your friends.
Editorial Staff at FreeWebMentor is a team of professional developers leads by Prem Tiwari View all posts by Editorial Staff
Tags: Combine Multiple Collections, How do I join two lists in Java, How to join two ArrayList in Java - Example, How to join two Lists in Java, Java programs, Java programs with examples, Java programs with output, Join Two List In Java & Remove Duplicates