Hai, today I have a short blog item. This is just because I am having fun with java generics. Check out the following piece of code. Will it compile? If you think it will compile, what will it print? If you think it won't compile, why not?
Use the comment option at the end of each blog item to give me your answer.
package generics.method.withinterface;
public interface Converter {
<E,T> E convert (T toBeConverted);
}
package generics.method.withinterface;
public class ExampleConverter implements Converter {
public <String, Integer> String convert(Integer toBeConverted) {
String retVal = "";
retval = toBeConverted.toString();
return retval;
}
}
package generics.method.withinterface;
public class Executer {
public static void main(String[] args) {
ExampleConverter converter = new ExampleConverter();
System.out.println(converter.convert(5));
}
}
After a few weeks I'll give the answer