zoukankan      html  css  js  c++  java
  • String 和Integer、int之间互转

    String转Integer

    String str = "10";
    Integer it = Integer.valueOf(str);
    

    Integer转String

    Integer it = new Integer(10);
    String str = it.toString();
    

    int 转Integer

    int i = 10;
    Integer it = new Integer(i);
    

    Integer转int

    Integer i = new Integer(10); 
    int k = i.intValue();
    

    int转String

    1、String s = String.valueOf(i);
    2、String s = Integer.toString(i);
    3、String s = “” + i;//会产生两个string对象

    String转int

    1、int i = Integer.parseInt(String);
    2、i=Integer.valueOf(s).intValue();//Integer.valueOf(s) 相当于 new Integer(Integer.parseInt(s)),也会抛异常,但会多产生一个对象

  • 相关阅读:
    Django路由系统
    修改数据库时区问题
    Django框架篇
    前端css
    前端html
    前端初识
    数据库3
    数据库2
    数据库1
    数据库初识
  • 原文地址:https://www.cnblogs.com/jiaorenzhan/p/10623943.html
Copyright © 2011-2022 走看看