專題總結:常見集合的迴圈輸出方式
一、list集合的迴圈輸出
listobjlist = new arraylist();
1) for (int i=0; ilist = new arraylist();
list.add("cheng");
list.add("zeng");
list.add("zhang");
iterator it = list.iterator();
while (it.hasnext())
4) 將list集合轉換為object型別的陣列,迴圈輸出
listlist = new arraylist();
list.add("cheng");
list.add("zeng");
list.add("zhang");
object obj = list.toarray();
for (int i=0; i
1) 將set集合轉換為迭代器iterator介面,並且迴圈輸出
setset = new hashset();
set.add("cheng");
set.add("zeng");
set.add("zhang");
iterator it = set.iterator();
while (it.hasnext())
2) 將set集合轉換為object型別的陣列
setset = new hashset();
set.add("cheng");
set.add("zeng");
set.add("zhang");
object obj = set.toarray();
for (int i=0;i
1) 直接迴圈map物件
mapmap = new hashmap();
map.put("1","cheng");
map.put("2","zeng");
map.put("3","zhang");
// 輸出鍵值
for (string key:map.keyset())
// 輸出value
for (string value:map.values())
2) mapmap = new hashmap();
map.put("1","cheng");
map.put("2","zeng");
map.put("3","zhang");
iterator it = map.entryset().iterator();
while (it.hasnext())
輸出結果:
3=zhang
2=zeng
1=cheng
java常見集合的迴圈輸出方式
一 list集合的迴圈輸出 listobjlist new arraylist 1 for int i 0 ilist new arraylist list.add cheng list.add zeng list.add zhang iterator it list.iterator while ...
php輸出方式,函式
1.單引號 2.雙引號 3.定界符 echo print print r die exit printf sprintf 講解return和die exit 的區別 m 5 return 中止指令碼執行 echo m function a echo 開始呼叫函式 return echo res a ...
JS 常用輸出方式
alert 要輸出的內容 在瀏覽器中彈出乙個對話方塊,然後把要輸出的內容展示出來 alert都是把要輸出的內容首先轉換為字串然後在輸出的 document.write 要輸出的內容 直接的在頁面中展示輸出的內容 console.log 要輸出的內容 在控制台輸出內容 value 給文字框 表單元素 ...