ITPub博客

首页 > IT职业 > IT职场 > 字符随机数排序

字符随机数排序

IT职场 作者:cookye 时间:2021-09-09 09:33:09 0 删除 编辑
package edu.eurasia.list.collection;

import java.util.*;

/**
 * 类名: 
 * 功能:(字符随机数排序)
 * 作者:admin 
 * 日期:2018/7/16  */ public class CollectionTest {     /**      * 对Integer泛型进行排序      */     public void testSort1(){         List integerList = new ArrayList();         //插入随机数         Random random = new Random();         Integer k;         for (int i = 0; i  stringList = new ArrayList();         stringList.add("microsoft");         stringList.add("google");         stringList.add("lenovo");         System.out.println("-------------排序前----------");         for (String string:stringList              ) {             System.out.println("元素" + string);         }         Collections.sort(stringList);         System.out.println("-------------排序后----------");         for (String string:stringList                 ) {             System.out.println("元素" + string);         }     }     /**      * 创建完List之后,往其中添加10条随机字符串      * 每条字符串的长度为10以内的随机整数      * 每条字符串的每个字符都为随机生成的字符,字符可以重复      * 每条随机字符串不可重复      *      */     public void homework(){         List stringList = new ArrayList();         int length = 10;         String str = "zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM1234567890";         for (int i =0;i


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1369/viewspace-2804612/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    91
  • 访问量
    502