Why use method local abstract inner classes

后端 未结 10 1770
名媛妹妹
名媛妹妹 2021-02-05 04:45

One of the legal modifiers you can use with method local inner classes is abstract.

For example:

public class Outer {
    public void method(){
        a         


        
10条回答
  •  温柔的废话
    2021-02-05 05:18

    the only real use I can imagine is for nodes in a data structure

    that way you can differentiate methods from sentinel nodes and normal data nodes which can be really handy in recursive algorithms and you don't have to null check each time

提交回复
热议问题