String str = "-1";
StringUtils.isNumeric(str)

返回的是false

StringUtils.isNumeric()方法在判断字符串是否是整数的时候,实现完全没有考虑到 - + 前缀的问题。

例如:【以下的一些特殊例子】

 StringUtils.isNumeric(null)   = false
 StringUtils.isNumeric("")     = true
 StringUtils.isNumeric("  ")   = false
 StringUtils.isNumeric("123")  = true
 StringUtils.isNumeric("12 3") = false
 StringUtils.isNumeric("ab2c") = false
 StringUtils.isNumeric("12-3") = false  
 StringUtils.isNumeric("12.3") = false  //小数
 StringUtils.isNumeric("-3")   = false   //负数

 

相关文章:

  • 2021-12-30
  • 2022-12-23
  • 2021-07-14
  • 2021-09-02
  • 2022-02-08
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-12
  • 2021-11-06
  • 2022-12-23
  • 2022-02-27
  • 2021-09-08
  • 2022-02-26
相关资源
相似解决方案