What does `public static <T> void main(String[] args)` stand for?

java

Solution

Let's look at each bit in turn:

- `public` - it's a public method, accessible to anything which has access to the class in which this is declared

- `<X>` - this is (somewhat bizarrely) a generic method with an unbound type variable `X`

- `static` - the method is related to the type in which it's declared, not any specific instance of the type

- `void` - the method doesn't return a value

- `main` - the name of the method

- `String[] args` - a single parameter, of type `String[]` and called `args`

`main` is the entry point used by the JVM. When you run:

java foo.bar.Baz

it will try to find a `main` method in class `foo.bar.Baz`. I've never seen a generic `main` method before, admittedly. For more about generics in Java, read the Java Generics FAQ.

Problem

What does `public static <X> void main(String[] args)` stand for? I tried to understand but didn't get. I know about `public static void main(String[] arg)`. Thanks in advance.

Original source