The first snippet uses a type variable named unconventionally String in the class declaration.
When the compiler sees String in main(String args), it takes it as the type variable and not as java.lang.String, which was your intention.
In the second snippet, you fully qualify String, so the compiler now knows that you meant java.lang.String.
Now you may ask, ok, so what's wrong with using type parameters in main()? Short answer: because main() is static. Long answer here: