Printing message on Console without using main() method

后端 未结 10 1757
情歌与酒
情歌与酒 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:23

    In a file called A.java

    class Con {
        String hi = "\n\nHello World\n\n";
    }
    

    You just have to compile the program on Windows. Not run it. :-P

提交回复
热议问题