0

I am following a tutorial that does not explain the syntax of this method declaration. Can someone explain what the first <T> right after the static keyword is for? When I hover over it in Android Studio is just says, "Class T extends Object".

public static <T> Resource<T> success(@NonNull T data) {
    return new Resource<>(Status.SUCCESS, data, null);
}
gig6
  • 307
  • 5
  • 16
  • 4
    It is a [generic parameter](https://docs.oracle.com/javase/tutorial/java/generics/boundedTypeParams.html). – Turing85 Sep 21 '20 at 21:47
  • Is this a case of it being a [Bounded Type Parameter](https://docs.oracle.com/javase/tutorial/java/generics/bounded.html)? If I understand this correctly, this limits the arguments that can be passed to this method to type T. Is that correct? – gig6 Sep 21 '20 at 22:24
  • Every generich parameter is - at least implicitly - bounded. The implicit bound is always `Object`. – Turing85 Sep 22 '20 at 07:47

0 Answers0