The basic transfer string type method of the type

1: Direct value + "" basic types;

2: tostring wrapper class static method (parameters) method, the object method is not tostring

  public String toString()

3: the static method of the string class valueOf (parameter).

        // basic string type to type 
        int NUM = 666 ; 
        String S = NUM + "" ; 
        System.out.println (S +100 ); 

        String S1 = Integer.toString (100 ); 
        System.out.println (S1) ; 

        String S3 = String.valueOf (NUM); 
        System.out.println (S3); 

        // the basic types of cast string
         // string is converted to an int 
        String S4 = "999" ;
         int num1 = Integer. the parseInt (S4); 
        System.out.println ( "basic types:" + s4);

Guess you like

Origin www.cnblogs.com/BatmanY/p/12074695.html
Recommended