Java examples for Language Basics:String
Java Sort String Array
import java.util.Arrays; public class Main { //from ww w. j av a2s . com public static void main(String args[]){ String[] strNames = new String[]{"John", "alex", "Chris", "williams", "Mark", "Bob"}; Arrays.sort(strNames); System.out.println("String array sorted (case sensitive)"); for(int i=0; i < strNames.length; i++){ System.out.println(strNames[i]); } Arrays.sort(strNames); System.out.println("String array sorted (case insensitive)"); for(int i=0; i < strNames.length; i++){ System.out.println(strNames[i]); } } }