<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ~~~ package arraylist.a4; import java.util.*; public class Test { public static void main(String[] args) throws Exception{ HashMap ee=new HashMap(); Sp sp1=new Sp("001","話梅",5f); Sp sp2=new Sp("002","薯片",8f); ee.put("001", sp1); ee.put("002", sp2);//鍵 值 if(ee.containsKey("002")){//不需要遍歷 System.out.println("該食品的信息為:"); Sp sp=(Sp)ee.get("002"); System.out.println(sp.getMingcheng()); System.out.println(sp.getJiage()); }else{ System.out.println("對不起,沒有該食品"); } } } class Sp{ private String bianhao; private String mingcheng; private float jiage; public Sp(String bianhao, String mingcheng, float jiage) { super(); this.bianhao = bianhao; this.mingcheng = mingcheng; this.jiage = jiage; } public String getBianhao() { return bianhao; } public void setBianhao(String bianhao) { this.bianhao = bianhao; } public String getMingcheng() { return mingcheng; } public void setMingcheng(String mingcheng) { this.mingcheng = mingcheng; } public float getJiage() { return jiage; } public void setJiage(float jiage) { this.jiage = jiage; } } ~~~ ![](https://box.kancloud.cn/79256ee93353937823c56a8739a5e8ae_163x122.png) HashMap的遍歷 ~~~ package arraylist.a4; import java.util.*; public class Test { public static void main(String[] args) throws Exception{ HashMap ee=new HashMap(); Sp sp1=new Sp("001","話梅",5f); Sp sp2=new Sp("002","薯片",8f); ee.put("001", sp1); ee.put("002", sp2);//鍵 值 /*if(ee.containsKey("002")){//不需要遍歷 System.out.println("該食品的信息為:"); Sp sp=(Sp)ee.get("002"); System.out.println(sp.getMingcheng()); System.out.println(sp.getJiage()); }else{ System.out.println("對不起,沒有該食品"); }*/ //遍歷 Iterator it =ee.keySet().iterator();//所有的鍵值都激活,都給取出來 while(it.hasNext()){//還有沒有下一個,有為真,沒有為假 String key=it.next().toString(); Sp sp=(Sp)ee.get(key); System.out.println("食品名稱:"+sp.getMingcheng()); System.out.println("食品價格:"+sp.getJiage()+"元"); } } } class Sp{ private String bianhao; private String mingcheng; private float jiage; public Sp(String bianhao, String mingcheng, float jiage) { super(); this.bianhao = bianhao; this.mingcheng = mingcheng; this.jiage = jiage; } public String getBianhao() { return bianhao; } public void setBianhao(String bianhao) { this.bianhao = bianhao; } public String getMingcheng() { return mingcheng; } public void setMingcheng(String mingcheng) { this.mingcheng = mingcheng; } public float getJiage() { return jiage; } public void setJiage(float jiage) { this.jiage = jiage; } } ~~~ ![](https://box.kancloud.cn/e842ccc8d6743738e71620e3249155e4_185x137.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看