The code will compile just fine and print - In first main()
Having two main methods is allowed as long as they are properly overloaded (yup, thats whts happening here - overloading of main
). The JVM will obviously only invoke the correct main method (with String array as an argument).