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 the difference between yielding and sleeping in java programming?

1085


What is time complexity algorithm?

997


What is pass by value?

902


Can a static member function access member variable of an object?

964


Explain the difference between transient and volatile in java?

962


What is the difference between throw and throws in java?

1038


What is empty list in java?

1034


Are strings immutable in java?

930


What is a boolean flag in java?

966


What is the advantage of preparedstatement over statement?

1054


Define nashorn in java8.

987


Can you tell me range of byte?

950


What is the Scope of Static Variable?

1170


Should you use singleton pattern?

904


What is a heavyweight component?

989