I have a Arraylist object, it has duplecate values also. Now
question is i want delete duplecate data in that objet with
out using Set?

Answer Posted / john

ArrayList al = new ArrayList();

al.add("A");
al.add("B");
al.add("A");
al.add("C');

for(int i = 0; i<al.size(); i++)
System.out.println(": " + al.get(i));

if(al.contains("A"))
al.remove("A");

for(int i = 0; i<al.size(); i++)
System.out.println("- " + al.get(i));

Is This Answer Correct ?    7 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the constructor and how many types of constructors are used in java?

527


Is it necessary for the port addresses to be unique? Explain with reason.

566


What is string :: npos?

571


How many threads does a core java have?

503


Define immutable object?

573






When a byte datatype is used?

559


What is hashset in java?

522


What is object data type?

556


Why do we need wrapper class?

530


What is a war file?

535


What is the inheritance?

540


Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain

1424


What is wrapper class html?

520


What is the difference between JDK and JVM?

622


What is the type of lambda expression?

531