import java.util.Arrays;

class Test{

    public static void main(String[] args) {
        String[][] strings={{"A","Z"},{"C","D","S"},{"L"}};
        for(String[] str:strings) {
            for(String s : str) {

As long as i understand Arrays.sort() method works for single dimensional array not for 2D array. but still 2D array consider as object as every array is an object in java.

so sort(Object[] a) method ll be called and it ll sort in ascending order. so it has to implement comparable interface.

String implement comparable interface but still i am getting here ClassCastException. can any one pl explain this why?

0 Answers