Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does <T extends mean?

Tags:

java

generics

I have seen a method like shown below:

protected <T extends ABC> T save( T Acd, boolean en) { 

What does it do? What is these type of method declarations called in Java?

like image 982
Nigel Thomas Avatar asked Oct 17 '12 06:10

Nigel Thomas


People also ask

What does T extends Comparable mean in Java?

Implementing the Extends Comparable<T> Interface in Java This method compares the object with the specified object for the order. It returns a negative integer if the object is less than specified. It will return zero if the object and the specified object are equal.

What is the difference between List <? Super T and List <? Extends T?

super is a lower bound, and extends is an upper bound.

What does Super t mean?

super T denotes an unknown type that is a supertype of T (or T itself; remember that the supertype relation is reflexive). It is the dual of the bounded wildcards we've been using, where we use ? extends T to denote an unknown type that is a subtype of T .

What does Bound mean in Java?

A bound is a constraint on the type of a type parameter. Bounds use the extends keyword and some new syntax to limit the parameter types that may be applied to a generic type. In the case of a generic class, the bounds simply limit the type that may be supplied to instantiate it.


1 Answers

It is called a generic method. This whole concept is called "Generics" in Java. That declaration means T can be any type that is subclass of ABC.

like image 104
basar Avatar answered Sep 20 '22 11:09

basar