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 =
No. One cannot directly define method in methods in java. Except special conditions, like pre declared methods in inbuilt classes. The preferable method is define method in same class and ofcourse call it.