C# to Java: where T : new() Syntax
- by Shiftbit
I am porting some C# code over to Java. I am having trouble with the where Syntax, specifically new(). I understand that where is similar to Java's generic: T extends FOO.
How I can replicate the new() argument in Java?
"The new() Constraint lets the compiler know that any type argument supplied must have an accessible parameterless--or default-- constructor." - MSDN
ie:
public class BAR<T> : BAR
where T : FOO, new()
Right now I have:
public class BAR<T extends FOO> extends ABSTRACTBAR {
public HXIT(T t){
this.value = t;
}
....
}