Converting a string to int in Groovy

前端 未结 13 2325
陌清茗
陌清茗 2020-11-30 18:45

I have a String that represents an integer value and would like to convert it to an int. Is there a groovy equivalent of Java\'s Integer.pars

13条回答
  •  余生分开走
    2020-11-30 19:10

    also you can make static import

    import static java.lang.Integer.parseInt as asInteger
    

    and after this use

    String s = "99"
    asInteger(s)
    

提交回复
热议问题