I'm working through some sample code and then this appeared:
public abstract class RandomPool<T> extends Pool {
//Class...
}
What's <>
used for? And why is just T
inside these? This seems to be very random for me. However, how can I use it in a longer perspective of making programs?
Thanks and tell me if I need to add more details!
See Java Generics
T stands for "Type"
Generics
T
is a placeholder for whatever type is used at runtime. For example you could use:
RandomPool<String> pool;
T
would refer to String
in that case.
Read the Java Generics Tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With