Online Java Compiler

import java.util.Arrays; public class Demo { public static void main(String args[]) throws Exception { String str[] = new String[]{"apple","orange","mango","guava", "melon"}; int n = str.length; System.out.println("The original array of strings is: "); for (int i = 0; i< n; i++) { System.out.println(str[i]); } Arrays.sort(str); System.out.println("The sorted array of strings is: "); for (int i = 0; i<n; i++) { System.out.println(str[i]); } } }