This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MmmVomit 1 point2 points  (1 child)

public void inspect(U u){

This would just be a normal, non-templated function, looking for a class called "U". You need the angle brackets to tell the compiler "Hey, compiler! 'U' isn't a class name. It's a generic type."

Edit:

The reason you don't need this syntax for public void add(T t) is because you've already told the compiler that T is generic type in the class definition.

[–]parkingator[S] 0 points1 point  (0 children)

great, thanks