public class Breakkker {
public static void main(String[] args) {
GenericParser parser = new GenericParser();
Long longValue = parser.parse(Long.class, "123");
System.out.println(longValue);
Integer intValue = parser.parse(Integer.class, "123");
System.out.println(intValue);
Float floatValue = parser.parse(Float.class, "123.45");
System.out.println(floatValue);
}
}
Output :
123
123
123.45
要你寫出
class GenericParser{
}