EDIT:-
How can I enable any Collection or Array to hold values from rowValue which is of double type so that values can be displayed on the browser.
public double[] FindClosestToMultiplesOfTen() {
double rowValue;
double []arr=new double[22];
int i=0;
try
{
con = getConnection();
stmt = con.createStatement();
String sql="some query";
stmt.executeQuery(sql);
rs = stmt.getResultSet();
while(rs.next())
{
for(int j=0; j<1; j++)
{
vals[i] = rs.getDouble(2);
}
i++;
}
}
catch( Exception e )
{
System.out.println("\nException "+e);
}
double max = Double.MIN_VALUE;
for (double v : vals) max = Math.max(max, v);
int bucketCount = 1 + (int)(max/10);
double[][] buckets = new double[bucketCount][3];
for (int i1 = 0; i1 < bucketCount; i1++){
buckets[i1][0] = Double.MAX_VALUE;
}
// iterate the rows
for (int i1 = 0; i1 < vals.length; i1++)
{
double v = vals[i1];
double mult = getMultipleOfTen(v);
double delta = Math.abs(mult - v);
int bIdx = (int)(mult / 10d);
if (buckets[bIdx][0] > delta)
{
buckets[bIdx][0] = delta;
buckets[bIdx][1] = i1;
buckets[bIdx][2] = v;
}
}
for (int i1 =1; i1 < buckets.length; i1++)
{
double[] bucket = buckets[i1];
rowValue = bucket[2];
System.out.println(rowValue);
}
return rowValue ;
}
I want to convert rowValue into an array ,so that I can display its values in browser. Currently only last value of rowValue is being displayed as I have taken it as a double type variable. I tried in this way
for (int i1 =1; i1 < buckets.length; i1++)
{
bucket = buckets[i1];
System.out.println(bucket);
}
return bucket;
But when I run this code then in-spite of bucket values,I get values of @ form.How to resolve it?
[D@1108727
[D@191e4c
[D@11415c8
[D@1a220e6 -----