zoukankan      html  css  js  c++  java
  • 整理类型转换

    字符串和字节数组
    String str = "罗长";

    byte[] sb = str.getBytes();//字符串转字节数组
    byte[] b={(byte)0xB8,(byte)0xDF,(byte)0xCB,(byte)0xD9};

    String str= new String (b);//字节数组转字符串

    字符串和字符数组
    string str = "mytest";  
     char[] chars = str.ToCharArray(); //字符串转字符数组

    char[] chs = new char[]{’a’,’b’,’c’,’d’,’e’};

     String s4 = new String(chs); //字符数组转字符串

    字符串和基本数据类型
    int i=Integer.parseInt("123");//字符串转基本数据类型

    //基本数据类型转字符串的三种方法

    “sum”=1+1;//1.双引号:“”+基本数据类型

    String i=String.valueOf(122);//2.调用String类中的valueof方法

    String i=Double.toString(12.1);//3.调用包装类中独有的tostring方法



    基本数据类型和包装对象
    Integer i=new Integer(111);//基本数据类型转包装类型对象

    Integer i=Integer.valueOf(111);//封装成包装类型

    int num=i.intValue();//包装类转基本数据类型

  • 相关阅读:
    echarts圆套圆
    两个对象深度比较,借鉴,记录
    js异步加载的方式
    elementUI使用el-card高度自适应
    如何在页面上实现一个圆形的可点击区域
    清除浮动
    水平垂直居中的几种方式
    BFC原理
    正则表达式
    Vue项目中难点问题
  • 原文地址:https://www.cnblogs.com/marswenze/p/13330987.html
Copyright © 2011-2022 走看看