• 金银铜排序程序


    package 单例模式;

    import java.awt.List;
    import java.util.ArrayList;
    import java.util.Arrays;

    public class Country implements Comparable<Country>
    {
        int jin;
        int yin;
        int tong;
        String name;
       

        public int compareTo(Country o) {
            // TODO Auto-generated method stub
            if(this.jin<o.jin)
            {
                return 1;
               
            }
            else if(this.jin>o.jin )
            {
               
                return -1;
               
            }
            else
            {
               
               
               
                if(this.yin<o.yin)
                {
                    return 1;
                   
                }
                else if(this.yin>o.yin)
                {
                   
                    return -1;
                   
                }
                else
                {
                   
                   
                    if(this.tong<o.tong)
                    {
                        return 1;
                       
                    }
                    else if(this.tong>o.tong)
                    {
                       
                        return -1;
                       
                    }
                    else
                    {
                        return this.name.compareTo(o.name );
                       
                    }
                   
                }
               
               
               
            }
           
        }
        public Country(int jin, int yin, int tong, String name) {
            super();
            this.jin = jin;
            this.yin = yin;
            this.tong = tong;
            this.name = name;
        }
       
        public static void main(String[] args) {
            ArrayList<Country> array=new ArrayList<Country>();
           
           
            Country c[]=new Country[4];
            
           
             c[0]=new Country(32,23,10,"China");
             c[1]=new Country(32,23,10,"Coo");
             c[2]=new Country(20,13,23,"Jpan");
             c[3]=new Country(20,12,34,"lisi");
             Arrays.sort(c);
             for(int i=0;i<4;i++)
             {
                 System.out.println(c[i].name +"--"+c[i].jin+"--"+c[i].tong+"--"+c[i].tong);
                
           

                  }
        }
       
    }

  • 相关阅读:
    转:1分钟解决git clone 速度慢的问题
    进程冻结学习笔记
    RT调度学习笔记(1)
    tracer ftrace笔记(2)——添加与使用
    Regeultor内核文档翻译_学习笔记
    一、Linux cpuidle framework(1)_概述和软件架构
    Python 将私有包自动上传Nexus私服
    Pychram 取消自动添加版本控制
    Python 3DES CBC 模式加密解密
    1588. 所有奇数长度子数组的和
  • 原文地址:https://www.cnblogs.com/hansongjiang/p/3784776.html
Copyright © 2020-2023  润新知