I'm not so sure.
In C #, I can do the following.
public class Helper<T> where T : new()
{
public static T SomeHelperFunction(string strValue)
{
return new T();
}
}
Here, the static method can explicitly use the type passed to the class Helper.
Here is my exact attempt in Java / Android
public class Helper<T> {
public static T SomeHelperFunction(String strValue){
}
}
Java complains about T used in SomeHelperFunction. Why does .Net allow this, but not Java, or am I missing something?
How can I create a .Net class in Java?
source
share