Results 1 to 2 of 2
- 02-02-2012, 11:25 AM #1
Member
- Join Date
- May 2011
- Posts
- 35
- Rep Power
- 0
Omit duplicate object that has same value in a collection class
Good day...
Set is able to omit duplicate value.
But, let say an object carry two attributes: attribute 1 and attribute2 and later it is added to a collection class.
Is anyone of you able to omit the object with same attribute 1 and attribute2?
Object obj1 = new Object();
obj1.attribute1 = "abc";
obj1.attribute2 = "def";
collection.add(obj1);
Object obj2 = new Object();
obj2.attribute1 = "abc";
obj2.attribute2 = "def";
collection.add(obj2);
Here, I hope the collection variable would carry one obj only instead of 2 obj...
- 02-02-2012, 12:53 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Preventing duplicate instances of an object
By monkeyhead in forum New To JavaReplies: 2Last Post: 11-07-2011, 07:28 PM -
How to update object in Collection.
By maynul in forum New To JavaReplies: 0Last Post: 10-28-2011, 06:14 PM -
How to Remove Duplicate object from collection
By santhoskumara in forum Advanced JavaReplies: 4Last Post: 08-04-2010, 07:07 PM -
Cannot insert duplicate key row in object
By losintikfos in forum New To JavaReplies: 3Last Post: 05-07-2009, 09:43 AM -
How do I omit an object when serializing?
By Hasan in forum Advanced JavaReplies: 1Last Post: 05-31-2007, 04:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks