Writing a function inside the main method - Java

前端 未结 7 2146
半阙折子戏
半阙折子戏 2020-12-06 11:36

Can you write a method inside the main method? For example I found this code:

public class TestMax {
    public static void main(String[] args) {
    int i =         


        
相关标签:
7条回答
  • 2020-12-06 12:36

    If you want to use it, in this scenario, make it static and place it in the class but outside the main method (as you have it in your code). Then you can call it from within main().

    0 讨论(0)
提交回复
热议问题