JAVA 陣列排序-Arrays.sort()
JAVA 陣列排序-Arrays.sort()
資料來源:http://alvinalexander.com/java/how-sort-java-string-array
import java.util.Arrays;
public class JavaSortStringArray
{
public static void main(String[] args)
{
// create a Java String array
String[] fruits = {"banana", "orange", "kiwi", "apple"};
// sort the array, using the sort method of the Arrays class
Arrays.sort(fruits);
// print the sorted results
for (String fruit : fruits)
{
System.out.println(fruit);
}
}
}
|