Fastest way to check if a String can be parsed to

2019-06-15 12:43发布

I know there's a million ways of doing this but what is the fastest? This should include scientific notation.

NOTE: I'm not interested in converting the value to Double, i'm only interested in knowing if it's possible. i.e. private boolean isDouble(String value).

7条回答
疯言疯语
2楼-- · 2019-06-15 13:46

I think trying to convert it to a double and catching the exception would be the fastest way to check...another way I can think of, is splitting the string up by the period ('.') and then checking that each part of the split array contains only integers...but i think the first way would be faster

查看更多
登录 后发表回答