why static need connect <T> in java?

Why do I need to add <T> when I declare a generic static method? If I don’t the compiler throws an error:

//doesn't compile
private static T[] finishToArray(T[] r, Iterator<?> it) {}

//compiles
private static <T> T[] finishToArray(T[] r, Iterator<?> it) {}

When you create a method in a generic class like this:

class MyClass<T> {
    public void doSomething(T input) {}
}

, doSomething belongs to the class, so the compiler knows type T (from the surrounding class).

If you have a static function, it can be in any class, even a non-generic one:

class MyClass {
    public static <T> void doSomething(T input) { };
}

If you left out the in this case, the compiler would not be able to tell what type to use.

EDIT:
to be more precise: the compiler would not be able that you are trying to use a generic type and would assume “T” to be the actual name of a class.

It should be

private static <T> T[] finishToArray(T[] r, Iterator<T> it) {

}

becouse static generic methods need generic declaration <T>, and this declaration will be differ from the class where this method located(as method could be in generic class as well)

public class MyClass<T> {

    private static <T> T[] finishToArray(T[] r, Iterator<T> it) {
    }
}

<T> could be different for class and method

In non static method you could put definition of generic declaration on class instance. You can’t do this for static methods, as they don’t need to have instance to execution.