【无标题】

这里写自定义目录标题

package com.qiku.day18;
import java.util.ArrayList;
import java.util.Random;
public class Zy01 {
        public static void main(String[] args){
            Random rand=new Random(System.currentTimeMillis());
            int[] arr=new int[10];
            ArrayList arrayList=new ArrayList();
            for(int i=0;i<10;i++){
                arr[i]=rand.nextInt(100);
                if (arr[i]>=10){
                    arrayList.add(arr[i]);
                }
            }
            System.out.println(arrayList);
        }
    }
package com.qiku.day18;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class zy02 {
        public static void main(String[] args) {
            List list = new LinkedList();
            String[] strs = {"12345","67891","12347809933","98765432102","67891","12347809933"};
            for (int i = 0; i < strs.length; i++) {
                if(list.contains(strs[i])){
                    list.remove(strs[i]);
                }
                list.add(strs[i]);
            }
            Iterator it = list.iterator();
            while (it.hasNext()){
                Object next = it.next();
                System.out.println("=="+next);
            }
            for (Object o : list){
                System.out.println("-->" + o);
            }
        }
    }

``import java.util.*;

public class zy03 {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        list.add(new Student("liusan", 20, 90));
        list.add(new Student("lisi", 22, 90));
        list.add(new Student("wangwu", 20, 99));
        list.add(new Student("sunliu", 22, 100));

        Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                if (o1.score == o2.score) {
                    return o1.age - o2.age;
                }

                return (int) (o2.score - o1.score);
            }
        });
        for (Student s : list) {
            System.out.println(s);
        }
    }
}

class Student implements Comparable<Student> {
    String name;
    int age;
    float score;

    public Student(String name, int age, float score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public Student() {
    }

    @Override
    public int compareTo(Student o) {
        if (this.score == o.score) {
            return this.age - o.age;
        }

        return (int) (o.score - this.score);
    }

    @Override
    public String toString() {
        return this.name + "[" + this.age + "]:" + this.score;
    }
}


import java.util.*;
public class zy04 {
        public static void main(String[] args) {
            Map<Integer,String> map = new HashMap<Integer, String>();
            map.put(1, "张三丰");
            map.put(2, "周芷若");
            map.put(3, "汪峰");
            map.put(4, "灭绝师太");
            Set<Integer> set = map.keySet();
            for (int i : set){
                System.out.println(i + "=" + map.get(i));
            }
            map.put(5, "郭靖");
            map.remove(1);
            map.put(2, "周林");
            Set<Map.Entry<Integer, String>> set1 = map.entrySet();
            for (Map.Entry<Integer, String> me : set1){
                System.out.println(me.getKey() + "=" + me.getValue());
            }
        }
    }

package com.qiku.day18;
import java.util.ArrayList;
import java.util.List;
    public class zyCountry {
        String name;

        public zyCountry(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static void main(String[] args){
            List<zyCountry> list=new ArrayList<zyCountry>();
            list.add(new zyCountry("科特迪瓦"));
            list.add(new zyCountry("阿根廷"));
            list.add(new zyCountry("澳大利亚"));
            list.add(new zyCountry("塞尔维亚"));
            list.add(new zyCountry("荷兰"));
            list.add(new zyCountry("尼日利亚"));
            list.add(new zyCountry("日本"));
            list.add(new zyCountry("美国"));
            list.add(new zyCountry("中国"));
            list.add(new zyCountry("新西兰"));
            list.add(new zyCountry("巴西"));
            list.add(new zyCountry("比利时"));
            list.add(new zyCountry("韩国"));
            list.add(new zyCountry("喀麦隆"));
            list.add(new zyCountry("洪都拉斯"));
            list.add(new zyCountry("意大利"));
            for(int i=0;i<4;i++){
                int count=0;
                for(int j=0;j<16;j++){
                    int k= (int) (Math.random()*16);
                    System.out.print(list.get(k).getName()+" ");
                    count++;
                    if(count==4){
                        break;
                    }
                }
                System.out.println();
            }
        }
    }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值