java--String與int相互轉換

字符串與int類型的互相轉換

String ---> int

//方式一:Integer(String s)
//demo:
    Integer i = new Integer("10");  // 10
    int a = i.intValue()

//方式二:static int parseInt(String s)
int b = Integer.parseInt("20");  //20

int ---> String

//demo:
    int a = 50;
    String s = a + "";
相關文章
相關標籤/搜索