Hello world and some interesting stuff

December 11, 2008

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

Some interesting things in this simple example

Everything has to be in a class

The first thing I noticed is that everything has to be in a class, even for something as easy and straighforward as the “Hello world!” mandatory example.

Actually not everything has to be in a class (yeah, I’m a contradicting man). Enumerations are, I think, the only thing that dont, however, if you look at them reaaaally closely, you’ll see that they are, more or less, like classes. I suppose I’ll talk/write about this in the near future

There has to be a main method

If you want to execute the example, be sure you have a main method, and that it accepts an array of arguments. This might sound pretty stupid for people that already know that language, but in Python for example, you don’t have this constraint.

There are some packages that are always at hand

There is no need to import the System package. I think that there are some other packages that are always at hand.

So many things in just a couple of lines…

cya!