I’m working on a program in Java and I have run into a small problem. I’m accepting user input that includes a number, but I have no way of knowing how that number is represented (i.e.: it could be “42”, “42.0”, “42.00001”, etc.). If I use, say, Float.parseFloat, it won’t accept integer strings (“42”), while if I use Integer.parseInteger, it won’t accept float strings (“42.0”). Is there any kind of generalized string-to-number conversion function in Java?
Thanks in advance.
You could use Float.parseFloat