Printing message on Console without using main() method

后端 未结 10 1762
情歌与酒
情歌与酒 2020-11-27 03:04

I was asked this question in an interview.

How to print message on console without using main() method?

10条回答
  •  难免孤独
    2020-11-27 03:17

    It was possible till java 6 to use System.out.println(); without main(). From java 7 onwards, it is not possible to do it with static block. It will still ask for main method in main class.

提交回复
热议问题