Results 1 to 4 of 4
- 02-08-2010, 01:31 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 44
- Rep Power
- 0
- 02-08-2010, 03:37 AM #2
There is probably a very simple way of doing this.Java Code:public class UniqueInt { public static void main(String[] args) { int[] a = {1,10,3,3,3,1}; int[] temp = new int[a.length-1]; int[] anotherTemp; boolean unique = true; temp[0] = a[0]; int count = 1; for (int tempInt : a) { for (int tempTempInt : temp) if (tempInt == tempTempInt) unique = false; if (unique) temp[count++] = tempInt; unique = true; } anotherTemp = new int[count]; //trim the array for (int i=0; i<count; i++) anotherTemp[i] = temp[i]; //print the new array for (int x : anotherTemp) System.out.println(x); } }Last edited by Lil_Aziz1; 02-08-2010 at 03:39 AM.
"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 09-11-2011, 01:18 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 4
- Rep Power
- 0
Re: find the unique values of a double array
How can I find the number of unique Strings of a String array?
e.g.
double a[] = {aab,aba,aca,aab,adc,zzz,aca};
How can I get 2?
Many thanks!
- 09-11-2011, 02:47 PM #4
Similar Threads
-
Find-Guru connects Teachers and Students in a unique way
By gonnalakshmi09 in forum Java SoftwareReplies: 0Last Post: 09-23-2009, 01:54 PM -
Problems with hashMap, has values in it but can't find them?
By mainy in forum New To JavaReplies: 5Last Post: 07-28-2009, 10:22 PM -
manipulation in double dimensional array
By akulkarni1234 in forum New To JavaReplies: 1Last Post: 07-19-2009, 07:37 PM -
mutliplicatio of double values
By katkamravi in forum New To JavaReplies: 2Last Post: 04-13-2009, 02:28 PM -
Unique element in an array
By revathi17 in forum New To JavaReplies: 2Last Post: 12-31-2007, 08:44 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks