Java核心代码例程之:SortDemo.java
2008-01-05 08:38:13 来源:WEB开发网核心提示:import java.util.*;/** * Demonstrates how to sort strings. ***/public class SortDemo{public static void main(String args[]) throws Exception{String names[] = ne
import java.util.*;
/**
* Demonstrates how to sort strings.
***/
public class SortDemo
{
public static void main(String args[]) throws Exception
{
String names[] = new String[5];
int i=0;
names[i++] = "Mary";
names[i++] = "John";
names[i++] = "David";
names[i++] = "Pam";
names[i++] = "Joe";
Arrays.sort(names);
for (int x=0; x < names.length; x++)
System.out.PRintln("Hello " + names[x]);
}
}
赞助商链接