Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / athira

package com.modon;

import java.util.ArrayList;

public class MyArrayList {

public static void main(String[] args) {

ArrayList<Object> dupList=new ArrayList<Object>();

ArrayList<Object> resultList=new ArrayList<Object>();
dupList.add(1);
dupList.add(2);
dupList.add(3);
dupList.add("D");
dupList.add("A");
dupList.add("F");
dupList.add("A");
dupList.add("A");
dupList.add(1.5);
dupList.add(1.50);
dupList.add(new String("A"));
dupList.add(new Integer(3));

for(Object s:dupList){

if(!resultList.contains(s))
resultList.add(s);
}

System.out.println("dupList: "+dupList.size());

System.out.println("resultList: "+resultList.size());

}

}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is character in data type?

962


What do you mean by formatting?

996


What is listnode in java?

992


When is the finally clause of a try-catch-finally statement executed?

1074


Why there are some null interface in java? What does it mean?

1127


What is Garbage Collection in Java

1084


What is an escape character in java?

1036


How many tetrahedral voids are there in bcc?

1097


List some features of the abstract class.

1069


If goto and const is reserve words than why it is not work in java?

1974


What is an infinite loop?

1255


What is hasnext in java?

1018


What is the difference between error and an exception?

1156


What is the difference between procedural and object-oriented programs?

973


Can a class declared as private be accessed outside it’s package?

1013