Most efficient way of converting String to Integer in java

后端 未结 11 2055
面向向阳花
面向向阳花 2020-11-29 08:00

There are many ways of converting a String to an Integer object. Which is the most efficient among the below:

Integer.valueOf()
Integer.parseInt()
org.apache         


        
11条回答
  •  无人及你
    2020-11-29 08:49

    If efficiency is your concern, use int: it is much faster than Integer.

    Otherwise, class Integer offers you at least a couple clear, clean ways:

    Integer myInteger = new Integer(someString);
    Integer anotherInteger = Integer.valueOf(someOtherString);
    

提交回复
热议问题