0

public abstract class AsyncTask<Params, Progress, Result> { }

Java-related question what kind of declaration is this <> at the end of the class name. something I have never studied in OOPS chapter in Java

  • Did you read e.g. https://stackoverflow.com/q/6607550/3001761? – jonrsharpe Aug 16 '21 at 13:40
  • https://stackoverflow.com/questions/6607550/what-does-t-angle-brackets-mean-in-java – BackSlash Aug 16 '21 at 13:41
  • Welcome to the world of [Generics](https://docs.oracle.com/javase/tutorial/java/generics/why.html)! They can be a bit confusing to get used to at first, especially regarding the limitations and use cases, but they are a powerful tool once you get used to them! – Tim Hunter Aug 16 '21 at 13:46

1 Answers1

0

That kind of declaration is used to determine what type of objects the java class will use.

In this case, since AsyncTask receives three parameters on execution/call, it determines the type of data the task instance will use:

public abstract class AsyncTask<Integer, String, String> { }

f.e -> new CreatedTask().execute(param1, param2, param3);

This is used in other structures too, such as ArrayLists, which use the "<>" to determine what type of objects the structure will store.