How to check if a String is numeric in Java

前端 未结 30 3283
盖世英雄少女心
盖世英雄少女心 2020-11-21 05:26

How would you check if a String was a number before parsing it?

30条回答
  •  耶瑟儿~
    2020-11-21 05:47

    I think the only way to reliably tell if a string is a number, is to parse it. So I would just parse it, and if it's a number, you get the number in an int for free!

提交回复
热议问题