码迷,mamicode.com
首页 > 其他好文 > 详细

找水王

时间:2019-06-20 23:56:30      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:style   bean   for   oid   code   als   bre   int   name   

public class Bean {
   
    public int number;
    public String id;
    public  String name;
    public String content;
    
    public Bean(int number,String id,String name,String content) {
        this.number=number;
        this.id=id;
        this.name=name;
        this.content=content;
    }

    public Bean() {};
    
    
    
    
    
    
}
import java.util.ArrayList;

import org.w3c.dom.ls.LSInput;

public class main {

    public static void main(String[] args) {
        
        ArrayList<Bean> list=new ArrayList<>();
        
        Bean bean1=new Bean(1, "2017001", "李奔", "我不是水王");
        Bean bean2=new Bean(2, "2017002", "张浩", "我不是水王");
        Bean bean3=new Bean(3, "2017003", "陈宇春", "我不是水王");
        Bean bean4=new Bean(4, "2017001", "李奔", "我不是水王");
        Bean bean5=new Bean(5, "2017004", "程超然", "我不是水王");
        Bean bean7=new Bean(7, "2017001", "李奔", "我不是水王");
        Bean bean6=new Bean(6, "2017005", "郭康乐", "我不是水王");
        Bean bean8=new Bean(8, "2017001", "李奔", "我不是水王");
        Bean bean9=new Bean(9, "2017004", "程超然", "我不是水王");
        int[]a=new int [list.size()+1];
        list.add(bean1);
        list.add(bean2);
        list.add(bean3);
        list.add(bean4);
        list.add(bean5);
        list.add(bean6);
        list.add(bean7);
        list.add(bean8);
        list.add(bean9);
        Bean temp = new Bean();
        System.out.println(list.size());
        for(int i=0;i<list.size();i++) {
            
            a[i]=0;
            for(int j=0;j<list.size();j++) {
                
                Bean bean=new Bean();
                bean=list.get(j);
                if(bean.id.equals(list.get(i).id)) {
                    a[i]++;
                }
            }
            
            if(a[i]>=list.size()/2) {
                temp=list.get(i);
                break;
            }
        }
        System.out.println(temp.name);
        
        
        
        
    }

}

 

找水王

标签:style   bean   for   oid   code   als   bre   int   name   

原文地址:https://www.cnblogs.com/zhang188660586/p/11062026.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!