欧美1区2区3区激情无套,两个女人互添下身视频在线观看,久久av无码精品人妻系列,久久精品噜噜噜成人,末发育娇小性色xxxx

題解 | 集合排序

集合排序

http://fangfengwang8.cn/practice/4d12899bb255459bbf2b3635b3d32817

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Customer customer1 = new Customer("小明",scanner.nextInt());
        Customer customer2 = new Customer("小軍",scanner.nextInt());
        Customer customer3 = new Customer("小紅",scanner.nextInt());
        List<Customer> customers = new ArrayList<>();
        customers.add(customer1);
        customers.add(customer2);
        customers.add(customer3);

        //write your code here......
        Collections.sort(customers);

        System.out.println(customers);

    }
}

class Customer implements Comparable<Customer>{
    private String name;
    private int consumption;

    public Customer(String name, int consumption) {
        this.name = name;
        this.consumption = consumption;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "name='" + name + '\'' +
                ", consumption=" + consumption +
                '}';
    }

    //write your code here......
    public int getConsumption(){
        return this.consumption;
    }

    public int compareTo(Customer c){
        return c.getConsumption() < this.getConsumption() ? -1 : 1;
    }
}

全部評論

相關(guān)推薦

掙K存W養(yǎng)DOG:散漫消極者淘汰,一眼坑爹。實(shí)習(xí)幾個(gè)月轉(zhuǎn)正的時(shí)候說你加班太少,能力還行態(tài)度不夠積極裁了,馬上老實(shí)。
點(diǎn)贊 評論 收藏
分享
被加薪的哈里很優(yōu)秀:應(yīng)該繼續(xù)招人,不會(huì)給你留崗位的
點(diǎn)贊 評論 收藏
分享
評論
點(diǎn)贊
收藏
分享

創(chuàng)作者周榜

更多
??途W(wǎng)
牛客企業(yè)服務(wù)