4 ms·
But you don't actually need the main: class a{static{System.out.println("Hello world");System.exit(0);}}
by benjiweber 16y ago
But you don't actually need the main:
class a{static{System.out.println("Hello world");System.exit(0);}}
- weavejester 16y agoI'm not sure that's any better. The static block is rarely used in Java, so I think you'd probably be better off teaching them how to use main. It also doesn't cut down much on the amount of boilerplate you need.