zoukankan      html  css  js  c++  java
  • Arrays类

    java.util.Arrays是一个与数组相关的工具类,里面提供了大量静态方法,用来实现数组的常见操作

    1.public static String toString(数组):将参数数组变成字符串(默认格式 [元素1, 元素2, 元素3, ...] )

    int[] array = {1, 2, 3};

    String str = Arrays.toString(array);                 

    sout(str);      //输出为[1, 2, 3]

    2.public static void sort(数组):按照默认升序(从小到大)对数组的元素进行排序。

    int[] array = {2, 10, 50, 12};

    Arrays.sort(array);

    sout(Arrays.toString(array));    //输出为[2, 10, 12, 50]

    字母也会按照升序来, ABCabc,大写在前,小写在后

  • 相关阅读:
    Memcached初识
    排序
    查找
    Redis初识

    C#
    C#
    C#
    C#
    C#
  • 原文地址:https://www.cnblogs.com/aoligei/p/12363297.html
Copyright © 2011-2022 走看看