Type Parameter

We can declare the generic type like this:

public interface Authenticator<SomethingGeneric> {  
    SomethingGeneric get();  // Note: this will be public abstract by default without having to explicitly declare `abstract` or `public`
}

Because we declared SomethingGeneric above in the interface, we can then use the same name to declare the type.

Now if the class choose the extends this interface, they have to do as the following:

public class User implements Serializable, Authenticator<User> {
	@Override  
	public User get() {  
	  return this;  
	}
}

Now SomethingGeneric is often too long, people normally annotate it E or T

Or we can declare the type parameter in the method itself:

public interface Authenticator<SomethingGeneric> {
    SomethingGeneric get();
	
	<T extends SomethingGeneric> void connect(T user);
}

In here before the return type, we declare all the parameter types. In which T is extended from SomethingGeneric. Then we can use T in our parameter.