Nested functions in Java

后端 未结 6 1394
礼貌的吻别
礼貌的吻别 2020-11-27 15:53

Are there any extensions for the Java programming language that make it possible to create nested functions?

There are many situations where I need to create methods

6条回答
  •  悲&欢浪女
    2020-11-27 16:15

    I hate to use the forbidden word but you could use a goto statement to create an an effective subroutine inside the method. It is ugly and dangerous but much easier than what was shown in previous answers. Although the private method with a call inside of the first method is much better, and serves you needs just fine. I don't know why you would want to use a nested method for something as simple as this.

提交回复
热议问题