Java: String, int into each other

int turn String

int A:

    A + ""
    String.valueOf (A)
    Interger.toString (A)
    is generally carried out using the above methods transforming

the first method efficiency is not good, java source of the '+' operator is overloaded using StringBuilder or StringBuffer achieved, and the new new StringBuilder StringBuilder.toString operations affect transformation efficiency. And this method will produce a plurality of objects, not recommended

internal call Interger.toString String.valueOf method, it is recommended that a third
String transfected int

    the Integer.parseInt (S)
    Integer.valueOf (S) .intValue ()

first the recommended method, a static method directly call

the first method the second method is called internally, but will generate more than objects

 

Original: https: //blog.csdn.net/LJJZJ/article/details/89459402

Guess you like

Origin www.cnblogs.com/peachh/p/12080583.html