Click here to Skip to main content
15,893,790 members
Home / Discussions / Java
   

Java

 
AnswerRe: Screen scrapping in java Pin
jschell8-May-12 13:49
jschell8-May-12 13:49 
AnswerRe: Screen scrapping in java Pin
TorstenH.8-May-12 18:52
TorstenH.8-May-12 18:52 
AnswerRe: Screen scrapping in java Pin
User 759941417-Jun-12 3:05
User 759941417-Jun-12 3:05 
QuestionMethod in Java Pin
trongduy7-May-12 4:21
trongduy7-May-12 4:21 
AnswerRe: Method in Java Pin
ekolis7-May-12 5:27
ekolis7-May-12 5:27 
AnswerRe: Method in Java Pin
koropatva7-May-12 20:38
koropatva7-May-12 20:38 
AnswerRe: Method in Java Pin
Richard MacCutchan7-May-12 22:00
mveRichard MacCutchan7-May-12 22:00 
QuestionHow to remove Duplicates in ArrayList Pin
B.Bryce7-May-12 4:02
B.Bryce7-May-12 4:02 
I have this the code below:

I used this code based in HashSet to remove duplicates but does not work:
public static <Enterprise> void removeDuplicates(ArrayList<Enterprise> list) {
XML
HashSet<Enterprise> h = new HashSet<Enterprise>(list);
        list.clear();
        list.addAll(h);
    }


public static void main(String args[]) {

ArrayList<Enterprise> array = new ArrayList<Enterprise>();

C#
array.add(new Enterprise("Micro System", 2001));
        array.add(new Enterprise("Delta Force", 1980));
        array.add(new Enterprise("Micro System", 2001));
        array.add(new Enterprise("Golden Mayer", 1781));

        removeDuplicates(array);

        for (Enterprise item : array) {
            System.out.println(item);
        }
    }
}



C#
public class Enterprise {

    private String name;
    private int yearFondation;

    public Enterprise(String name, int yearFondation) {
        this.name = name;
        this.yearFondation = yearFondation;
    }

    public String getname() {
        return name;
    }

    public int getYearFondation() {
        return yearFondation;
    }

    public void setname(String name) {
        this.name = name;
    }

    public void setYearFondation(int yearFondation) {
        this.yearFondation = yearFondation;
    }

    @Override
    public String toString() {
        return "Enterprise : " + name + "   Year of Fondation : " + yearFondation;
    }
}

AnswerRe: How to remove Duplicates in ArrayList Pin
ekolis7-May-12 5:31
ekolis7-May-12 5:31 
GeneralRe: How to remove Duplicates in ArrayList Pin
BobJanova8-May-12 3:09
BobJanova8-May-12 3:09 
AnswerRe: How to remove Duplicates in ArrayList Pin
koropatva7-May-12 20:28
koropatva7-May-12 20:28 
QuestionEducational Imap client Pin
Pinifiux6-May-12 23:17
Pinifiux6-May-12 23:17 
AnswerRe: Educational Imap client Pin
TorstenH.7-May-12 1:07
TorstenH.7-May-12 1:07 
QuestionHashMap... am I doing it wrong? Pin
Stephen Dycus2-May-12 12:17
professionalStephen Dycus2-May-12 12:17 
AnswerRe: HashMap... am I doing it wrong? Pin
Stephen Dycus2-May-12 12:55
professionalStephen Dycus2-May-12 12:55 
GeneralRe: HashMap... am I doing it wrong? Pin
Peter_in_27802-May-12 13:06
professionalPeter_in_27802-May-12 13:06 
GeneralRe: HashMap... am I doing it wrong? Pin
Stephen Dycus2-May-12 13:07
professionalStephen Dycus2-May-12 13:07 
AnswerRe: HashMap... am I doing it wrong? Pin
Peter_in_27802-May-12 13:05
professionalPeter_in_27802-May-12 13:05 
GeneralRe: HashMap... am I doing it wrong? Pin
Stephen Dycus2-May-12 13:06
professionalStephen Dycus2-May-12 13:06 
Question-Xlint Pin
jigar - shah 22-May-12 7:06
jigar - shah 22-May-12 7:06 
AnswerRe: -Xlint Pin
Stephen Dycus2-May-12 7:45
professionalStephen Dycus2-May-12 7:45 
Questionproject for you Pin
silverbuyer1-May-12 18:39
silverbuyer1-May-12 18:39 
QuestionJava + OpenGL ES: Test for Transparency? Pin
Stephen Dycus1-May-12 15:38
professionalStephen Dycus1-May-12 15:38 
GeneralRe: Java + OpenGL ES: Test for Transparency? Pin
Stephen Dycus2-May-12 6:45
professionalStephen Dycus2-May-12 6:45 
QuestionJTables Implementation Pin
pawlu8929-Apr-12 1:53
pawlu8929-Apr-12 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.