第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求大神幫忙看看。

求大神幫忙看看。

小小雨點 2016-10-19 21:22:58
package?text2; import?java.io.File; import?java.io.IOException; import?java.util.ArrayList; import?java.util.HashMap; import?java.util.List; import?java.util.Map; import?java.util.Scanner; import?java.util.Set; import?java.util.TreeSet; class??NameBean?implements?Comparable<NameBean>{ private?String?name; private?Integer?count; public?int?compareTo(NameBean?bean)?{ if(this.count?>?bean.count){ return?1; }else?if(this.count?<?bean.count){ return?-1; }else{ return?this.name.compareTo(bean.name); } } public?NameBean(String?name,?Integer?count)?{ super(); this.name?=?name; this.count?=?count; } public?String?toString()?{ return?name?+"出現(xiàn),?"?+?count; } } public?class?Demo2?{ public?static?void?main(String[]?args)?throws?IOException?{ List<String>?names?=?new?ArrayList<String>(); Map<String,?Integer>?nameMap?=?new?HashMap<String,?Integer>(); //搞一個集合,裝學生對象 Set<NameBean>?set?=?new?TreeSet<NameBean>(); Scanner?sc?=?new?Scanner(new?File("out/student.txt")); while?(sc.hasNextLine())?{ String?line?=?sc.nextLine(); String[]?arr?=?line.split(","); String?name?=?arr[1]; names.add(name); if?(nameMap.containsKey(name))?{ Integer?val?=?nameMap.get(name); nameMap.put(name,?val?+?1); }?else?{ nameMap.put(name,?1); } } System.out.println(names); System.out.println(nameMap); //================ for?(Map.Entry<String,?Integer>?entry?:?nameMap.entrySet())?{ //if?(entry.getValue()?>?1)?{ //System.out.println(entry.getKey()?+?"-->"+?(entry.getValue()?)); //} set.add(new?NameBean(entry.getKey(),entry.getValue())); } System.out.println(set); } }請問public?int?compareTo(NameBean?bean)?{ if(this.count?>?bean.count){ return?1; }else?if(this.count?<?bean.count){ return?-1; }else{ return?this.name.compareTo(bean.name); } }里面的bean.count?與bean.name代表的是誰?this.count在與誰(bean.count)比較?this.count?又代表誰呢? 所返回的正數(shù)負數(shù)是什么意思?有什么用?求大神指點,有點暈。
查看完整描述

1 回答

  • 1 回答
  • 1 關注
  • 1089 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號