• java代码排序问题


    总结:

    package com.ja;
    
    import java.util.Arrays;
    import java.util.Collections;
    
    public class mili {
    	public static void main(String[] args) {
    		int a[] = new int[] { 3, 25, 231, 1, 21, 4, 12 };
    		Arrays.sort(a);
    		for (int i = 0; i < a.length; i++) {
    			System.out.print(a[i] + " ");
    		}
    		String b[] = new String[] { "daf", "A", "rRT", "TE", "erE" };
    		Arrays.sort(b);
    		for (int i = 0; i < b.length; i++) {
    			System.out.print(b[i] + " ");// 字符串排序先大写后小写
    		}
    		String c[] = new String[] { "WTR", "cTW", "at", "Edf", "Xt", "id", "us" };
    		Arrays.sort(c, String.CASE_INSENSITIVE_ORDER);// 字符串忽略大小写,排序
    		for (int i = 0; i < c.length; i++) {
    			System.out.print(c[i] + " ");
    		}
    		String w[] = new String[] { "Ex", "wew", "ADE", "ade", "Sdf" };
    		Arrays.sort(w, Collections.reverseOrder());// 反向排序,使用对象类型,c即为对象名
    		for (int i = 0; i < w.length; i++) {
    			System.out.print(w[i] + " ");
    		}
    		String d[] = new String[] { "fwq", "Adf", "ewa", "DQA" };
    		Arrays.sort(d, String.CASE_INSENSITIVE_ORDER);// 忽略大小写的反向排序
    		Collections.reverse(Arrays.asList(d));
    		for (int i = 0; i < d.length; i++) {
    			System.out.print(d[i] + " ");
    		}
    	}
    
    }
    

      

  • 相关阅读:
    GridView
    BaseAdapter
    ArrayAdapter,SimpleAdapter
    消息机制,Handler
    进度条对话框
    随机二选一
    (二十五)WebDriver API之上传文件
    (二十四)WebDriver API之警告框处理
    linux常用命令大全
    (二十三)WebDriver API之多窗口切换
  • 原文地址:https://www.cnblogs.com/langlove/p/3413684.html
Copyright © 2020-2023  润新知