1.匿名内部类可以使你的代码更加简洁,你可以在定义一个类的同时对其进行实例化。它与局部类很相似,不同的是它没有类名,如果某个局部类你只需要用一次,那么你就可以使用匿名内部类(Anonymous classes enable you to make your code more concise. They enable you to declare and instantiate a class at the same time. They are like local classes except that they do not have a name. Use them if you need to use a local class only once.)
本节包括以下几个方面:

  1. 定义匿名内部类
  2. 匿名内部类的语法
  3. 访问作用域的局部变量、定义和访问匿名内部类成员
  4. 匿名内部类实例

    重点看区别(局部内部类和匿名内部类)

    image.png

image.png

image.png