How can i convert a string to a abstract number, provided string is any valid number in java (say int, long, double etc).
I will not know the type of number in the string, so i can't use specific primitive parsing (like Integer.parseInt, Long.parseLong etc). Is there any generic way to convert it?
Eg:
Use NumberFormat. Number cannot be instantiated because it is an abstract class.
Number number = NumberFormat.getInstance().parse(string);