Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Wayne Crawford   on May 28 In Java Category.

  
Question Answered By: Bama Cohen   on May 28

Take a look at java.util.Arrays sort  method. It
DOES work. I tried the following code, just for
testing:

import java.util.Arrays;

public class Test
{
public static void main(String[] args)
{
double[] arr = {3.5d, 4.5d, -1.7d, 4.4d,
2.000001d, 2.0001d, 1d };

for (int i=0; i<arr.length; i++)
{
System.out.println("arr[" + i + "]: " +
arr[i]);
}

Arrays.sort(arr);

for (int i=0; i<arr.length; i++)
{
System.out.println("arr[" + i + "]: " +
arr[i]);
}
}
}


What are the values  that you are placing into the
array? How are you using the values? When you get 0s,
how are you figuring out that they are, indeed, 0?
Could it be a printing/formatting issue?

Share: