answersLogoWhite

0

First we need to have two lists whcih we need to compare.

and try to incorporate it in below code :

import java.util.*;

public class ExampleTry {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

List al1=new ArrayList();

al1.add("a1");

al1.add("a2");

al1.add("a3");

List al2=new ArrayList();

al2.add("a1");

al2.add("a2");

al2.add("a3");

al2.add("a4");

al2.add("a5");

for(Object objList:al1){

if(al2.contains(objList)){

al2.remove(objList);

}

}

System.out.println("Value in list"+al2);

}

}

Output :

Value in list[a4, a5]

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How do you campaire Strings in java?

String class in Java has an 'equals' method that can be used to compare strings.


Why java is secured compare with other language?

Because there is an access specifier called private in java by which security can be provided


System.out.flush function in java?

it will show output fastly. when compare with system.out.print


Which is better java or Ajax?

you mean JavaApplet or Ajax? I do not think you can compare java as a whole and AJAX. Ajax is a simple implementation of JAvascript .


How many types of java programing?

Java 2 Programming Language Java Server Pages (JSP) Java Beans (JB) Enterprise Java Beans (EJB) Java Script (JS) Java Server Faces (JSF) JDBC Java 2 Enterprise Edition (J2EE) by jaan from dubai


What is the meaning of the 2 in j2ee?

Java 2 Platform Enterprise Edition. The 2 means that it is Java number 2.


What is the difference between J2EE and JEE?

j2ee is the old naming of the java enterprise edition, in the early history java was called simply java afterward sun created a new version of java called java 2 subsequent updates followed the theme OJ java 2 1.3 java 2 1.4 java 2 1.5 sun realized that this naming is making confusion to people so it dropped the 2 so j2ee became jee :)


What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.


Where can one find a company that specializes in Java hosting in Calgary?

Netfocusconsulting's online website lists many companies located in Calgary, Canada that specialize in Java hosting. Netfocus Consulting Inc. is based in Calgary, Alberta.


What has the author Cay S Horstmann written?

Cay S. Horstmann has written: 'Core Java 2' -- subject(s): Java (Computer program language), Java 2.


What websites offer the ability to compare medical insurance?

A great place to compare medical insurance is healthcompare.com. You can also compare insurance plans at health.usnews.com/healthplans which lists most of the top insurance providers.


What is meant by java API and how it is helpful to the java programmer?

API stands for Application Programming Interface It usually referrs to documentation on how a specific class works. It lists,describes, and details the class' methods, properties, constructors, etc.. Here is a link for a the API of the String class in Java: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html