Akshay Naik :
I was reading about how monomorphisation works in Rust, does java work in same way.
Lets say I create below file.
public class DummyDTO<T> {
T data;
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
and use new DummyDTO<Integer>()
& new DummyDTO<Float>()
will java compiler create two different files for each, Integer and Float or it will Simply replace T
with Object and will do casting everywhere?
Elliott Frisch :
Type erasure. The second one. Literally, replace T
with Object
and it will insert casts as necessary.