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

    A.  char 转换String 

    char c = 'a'; 
    String str = String.valueOf(c);

    B.整数 int 转换成字串 String 
    1.) String s = String.valueOf(i);

    2.) String s = Integer.toString(i); 

    3.) String s = "" + i;

    C.int转换float

    int f1 = 2;

    float fl = (float100;

    D.float转换int

    float a=1.222f;

    int b=(int)a;
     
     
     
    E.int转换long
    int a = 1;
    long b = aL;
     
     
     
    F.long转换int

    long a = 10L;

    int b = (int) a;

    H.String转换Int

        String grandeId = "1237";

    Integer.parseInt(gradeId);



     I.String 转换double

    Double.parseDouble("project");

    暂时写这些,遇到再补。

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");   //按照2018-04-08 13:08:24:456的格式输出时间
    sdf.format(new Date());

    What do you want to be?
  • 相关阅读:
    JavaScript 弹窗
    创建对象构造器
    DOM事件
    document对象“还在更新”
    JavaScript 闭包
    使用 "use strict" 指令
    constructor 属性
    2019暑期集训第一周小结
    无向图求割边
    矩阵快速幂
  • 原文地址:https://www.cnblogs.com/CatsBlog/p/8744362.html
Copyright © 2011-2022 走看看