List<double[]> x = new ArrayList<double[]>();
x.add(new double[] { 1, 1.2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
How can I use java code find not integer type(1.2) in x List?
I'm new to Java :P But I think direct comparison wouldn't be good?
double a = 1;
double b = 1;
double c = a-b;
if (Math.abs(c) == 0) {...}
Basically set another primitive to the value your looking for. Subtract that value from the list. If one of the index's contains 1.2 than 1.2-1.2 = 0? Than you know where it is?
EDIt: I just understood the question. So here is the updated answer
List<double[]> x = new ArrayList<double[]>();
x.add(new double[] { 1, 1.2, 2.9, 3.9, 4.1, 5.5, 6, 7, 8, 9, 10, 11, 12 });
List<Double> foundDoubles = new ArrayList<Double>();
int i = 0;
for(double d : x.get(0)) {
i = (int)d;
if(i != d) {
foundDoubles.add(d);
}
}
for(double d : foundDoubles) {
System.out.println(d);
}
}
double with another double using == you will have a bad time...
1.2is not an integer.for-loop?xis aList<double[]>so you won't be able to find anything in it butdouble[]objects. Do you actually mean find a value (likelydoublenotint) in one of thedouble[]objects inx?