Results 1 to 2 of 2
- 12-20-2011, 12:05 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
- 12-20-2011, 12:46 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Re: Checking if a value only apears once in an array
You can check that an array contains no duplicates by making a Set out of it and checking it's size. Or you can use for loops and check that no entry in the array is followed by an entry with the same value.
You can constrain the values in an array by simply never adding any value that you consider illegal. After the fact, the for loop mentioned above can also check that each value is good. A for loop can also keep track of the total.
Similar Threads
-
checking a 2D Array off a 1D Array and outputting result
By leoshiner in forum New To JavaReplies: 1Last Post: 11-13-2011, 11:25 AM -
checking array items are equal
By trishtren in forum New To JavaReplies: 5Last Post: 10-16-2011, 12:23 PM -
Checking to see if Array is sorted
By pytho in forum New To JavaReplies: 5Last Post: 07-06-2011, 01:39 AM -
Checking ascending order of array
By counterfox in forum New To JavaReplies: 3Last Post: 10-22-2010, 10:44 PM -
Checking if something is equals to anything in an array
By Sapster in forum New To JavaReplies: 5Last Post: 03-19-2010, 12:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks