Results 1 to 4 of 4
- 03-11-2009, 05:30 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
- 03-11-2009, 06:27 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Create a Set of somekind (HashSet perhaps), add all the elements to the Set. "Set" ensures there is only 1 copy of each unique instance.
Uniqueness is determined via the "equals" method of the class in question. For Integer, "equals()" will return true for instances that have equal intValues().
- 03-11-2009, 05:02 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Easiest method would be to create a new array and copy the contents of the old one into it 1 by 1. if an element is repeated, it is not added into the new array.
if you don't want to create a new array, then u use a for-loop to search through the entire array for repeated elements and replace them with zero. then print all non-zero elements
-
Similar Threads
-
java prob...
By palms_09@yahoo.com in forum New To JavaReplies: 2Last Post: 01-09-2009, 04:09 PM -
for each prob
By kusumathatavarthi in forum New To JavaReplies: 7Last Post: 05-21-2008, 01:00 PM -
Prob with an exercise
By jhetfield18 in forum New To JavaReplies: 4Last Post: 02-15-2008, 06:11 PM -
having prob with Exception
By eva in forum New To JavaReplies: 1Last Post: 01-04-2008, 05:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks