美文网首页
Arrays&Math

Arrays&Math

作者: 滴答大 | 来源:发表于2018-10-11 14:05 被阅读9次

1、数组工具类Arrays
/*
* tostring()
* sort()
* */

public static void main(String[] args) {

    int [] array = {12,413,3};
    String str = java.util.Arrays.toString(array);
    System.out.println(str);


    java.util.Arrays.sort(array);
    System.out.println(java.util.Arrays.toString(array));


}

2、练习题


屏幕快照 2018-10-11 下午12.14.16.png
    public static void main(String[] args) {
    String str = "dfgdsdkasiuytqwrds";
    char [] charArr = str.toCharArray();

    System.out.println(Arrays.toString(charArr));
    //[d, f, g, d, s, d, k, a, s, i, u, y, t, q, w, r, d, s]

    Arrays.sort(charArr);
    System.out.println(Arrays.toString(charArr));
    //[a, d, d, d, d, f, g, i, k, q, r, s, s, s, t, u, w, y]

    //反向输出
    //ywutsssrqkigfdddda
    for (int i = 0; i < charArr.length; i++) {
        char cha = charArr[charArr.length-1-i];
        System.out.print(cha);
    }

}

二、Math

    public static void main(String[] args) {

    System.out.println(Math.abs(3.45));//绝对值
    System.out.println(Math.ceil(3.45));//向上取整
    System.out.println(Math.floor(3.45));//向下取整
    System.out.println(Math.round(3.45));//四舍五入

}

相关文章

  • Arrays&Math

    1、数组工具类Arrays/** tostring()* sort()* */ 2、练习题 二、Math

  • 数学函数

    import math math.sin math.log10 math.sqrt math.pi

  • python内置函数

    math模块 在使用前导入math模块 import math 常用方法 math.pow()方法 math.p...

  • 2018-03-17

    math库 >>>import math #导入math库 >>>math.ceil(1.03) #向上取整 >>...

  • Python Basic

    # Import the math package import math as math # Calculate...

  • 06-内置对象

    Math Math.PI // 圆周率 Math.random() // 生成随机数 Math.f...

  • 2018.7.23

    Math 1.Math.ceil() 上取整 alert(Math.ceil(3.5)) alert(Math.c...

  • (¦3[▓▓]

    Math 1.Math.ceil() 上取整 alert(Math.ceil(3.5)) alert(Math.c...

  • python 地板除法(floor)和截断除法(trunc)

    math.floor() & math.trunc() math.floor 和 math.trunc的官方不同版...

  • JavaScript--Math对象

    Math对象属性 Math.E2.718281828459045Math.LN20.693147180559945...

网友评论

      本文标题:Arrays&Math

      本文链接:https://www.haomeiwen.com/subject/rbcbaftx.html