+ 8

How to parse Number in java?

I want to know how to parse a number from a string without parsing it as any specific type of number(i.e not as an integer, long, double or float) but just as a number. For example: String num = "99.34"; Object number = Number.parseNumber(num); Is there any function lyk that?

1st Oct 2017, 11:34 AM
David Akhihiero
David Akhihiero - avatar
7 Answers
+ 7
@Yerucham : Sorry for that, but I did understand it from your question. Maybe you were trying to ask somethin' else. Thank you @Taylor :))
1st Oct 2017, 1:38 PM
Dev
Dev - avatar
+ 6
I don't tink my question is understood, I want a function that will parse a string a give a double if d string is a double and an int if d string is an int
1st Oct 2017, 12:45 PM
David Akhihiero
David Akhihiero - avatar
+ 6
thank u Taylor
1st Oct 2017, 1:21 PM
David Akhihiero
David Akhihiero - avatar
+ 3
@Martin Taylor it's is possible When you get the string look into the content of the string and choose what type you want for it? You can peep at string with regExp or just getChars() method.
2nd Oct 2017, 12:42 AM
Ore
Ore - avatar