# Thread: find the unique values of a double array

1. Member Join Date
Jan 2010
Posts
44
Rep Power
0

## find the unique values of a double array

How can I find the unique values of a double array?
e.g.
double a[] = {1,10,3,3,3,1};
How can I get {1,3,10}?

Many thanks!  Reply With Quote

2. ## 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 = a;
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);

}

}```
There is probably a very simple way of doing this.
Last edited by Lil_Aziz1; 02-08-2010 at 03:39 AM.  Reply With Quote

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.
How can I get 2?

Many thanks!  Reply With Quote

4. ## Re: find the unique values of a double array  Reply With Quote