Java Arrays.sort(float[] a)
Syntax
Arrays.sort(float[] a) has the following syntax.
public static void sort(float[] a)
Example
In the following code shows how to use Arrays.sort(float[] a) method.
// w ww. j a v a2s.co m
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// initializing unsorted float array
float fArr[] = {13.2f, 1.2f, 0.7f, 1.2f, 4.5f};
System.out.println(Arrays.toString(fArr));
// sorting array
Arrays.sort(fArr);
System.out.println(Arrays.toString(fArr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »