posted 23 years ago
No, valueOf() and parseDouble() are virtually identical - the difference is that the former returns a double (primitive) and the latter returns a Double (wrapper class). In fact valueOf() calls the exact same code as parseDouble() internally, and then it creates a Double wrapper for the result, so it will take slightly longer.
Anoop- have you tested parseDouble() yourself to see if it's really too slow for your application? In general I don't see any reason why it should be overly slow; I've never noticed a problem with it. Are you parsing a lot of values, that the time it takes to parse is noticeable? I don't think there's really a good alternative in the standard libraries. You might be able to write something yourself that parses faster than the standard library, if you can assume some additional restrictions on hte input - e.g. no leading or trailing spaces or zeroes; no values that might overflow a double variable; maybe others. But I doubt you'd improve on it by a whole lot, and it would be easy to introduce new bugs into the algorithm. Good luck...
"I'm not back." - Bill Harding, Twister