Hacker News new | ask | show | jobs
by Kototama 1019 days ago
Nothing like a short

class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }

to start a nice journey into programming, right?

2 comments

Dude, Java has changed. You don't need `public static void main` anymore.

https://medium.com/@shwetha.hey/java-21-no-more-public-stati...

Also you can do

    new {
      System.out.println("Hello, world!");
    }
You forgot to declare the package name! How are you going to properly load the hello.world.example package?
Ah ah :-) It has been so long I actually copied it from a website.

But I had to look after your comment and Java can cope with no package declaration! https://stackoverflow.com/questions/2335211/what-is-the-defa...