It is valid because it allows subclasses of String or the String class itself.

Please UseCodeTags when posting code. It will highlight your code and make it much easier to read. It probably will also increase the number of people helping you. You can edit your post with the button.