How are Anonymous inner classes used in Java?

后端 未结 18 1379
孤独总比滥情好
孤独总比滥情好 2020-11-21 05:19

What is the use of anonymous classes in Java? Can we say that usage of anonymous class is one of the advantages of Java?

18条回答
  •  遥遥无期
    2020-11-21 05:46

    You can use anonymous class this way

    TreeSet treeSetObj = new TreeSet(new Comparator()
    {
        public int compare(String i1,String i2)
        {
            return i2.compareTo(i1);
        }
    });
    

提交回复
热议问题