CtrlAltDelete CtrlAltDelete - 1 year ago 97
Java Question

Not understanding method types

Teaching myself Java and I came across a confusing part about method types/return types?

For example what does the

right after the
represent in the method below? How can it return a type of

public <U> IList<U> map(IFunc<T, U> f) {
return new ConsList<U>(f.apply(this.first), this.rest.map(f));

Answer Source

It is called as a Type Paremeter. It represents a generic class that is representing within that map method. What I meant by generic class is, any class you can come up with. It can be MyHouse.java, MyCar.java, String.java, etc

IList<U> is, it's a IList that contains U type objects.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download