3 ms·
You forgot the class: class M { public static void main(String[] a) { System.out.println("Hello World"); } } The problem with using this as learning mater
by weavejester 16y ago
You forgot the class:
class M { public static void main(String[] a) { System.out.println("Hello World"); } }
The problem with using this as learning material is that the teacher has to treat the majority of the code as "magic" until the student is ready to learn about classes, access permissions, methods, arrays, namespaces, types and so forth.
In many other languages, there's much less boilerplate to handwave away:
print("Hello World")
puts "Hello World"
(println "Hello World")
- benjiweber 16y agoBut 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.