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

15y 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 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


What is the diff between java 2 and core java?

Java 2 was an umbrella term used to refer to the second major release of the Java platform, which was introduced in December 1998. It encompassed several editions, including the Java Standard Edition (Java SE), Java Enterprise Edition (Java EE), and Java Micro Edition (Java ME). The Java 2 platform brought significant enhancements, including improved performance, new APIs, enhanced security, and better support for web-based applications. Core Java: Core Java, on the other hand, is not a specific version or edition of Java, but rather a term used to refer to the fundamentals of the Java programming language. It represents the foundational concepts and features that are common across different editions of Java. Core Java typically covers topics such as syntax, data types, control structures, object-oriented programming (OOP) principles, exception handling, input/output operations, and basic libraries. To summarize, Java 2 is an outdated term that was used to refer to the second major release of the Java platform, while Core Java is a more general term used to describe the foundational concepts and features of the Java programming language. In the current Java ecosystem, the term Java SE is used to refer to the standard edition, which is the most commonly used edition for general-purpose Java development.