Writing a function inside the main method - Java

前端 未结 7 2153
半阙折子戏
半阙折子戏 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:26

    No, you can't declare a method inside another method.

    If you look closely at the code you provided it is just a case of bad formatting, the main method ends before the max method is declared.

提交回复
热议问题