当前位置:网站首页>List set map queue deque stack
List set map queue deque stack
2022-07-06 13:20:00 【[email protected]】
List
Mode one :for loop
for(int i = 0;i = list.size();i++){
System.out.println(list.get(i));
}
Mode two :for each Loop traversal
for(String s : list){
System.out.println(s);
}
Mode three :iterator Iterator traversal
Iterator<String> it = list.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
Set
Mode one :for each
for(String s : set){
System.out.println(s);
}
Mode two :iterator Iterator traversal
Iterator it = set.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
Map
Mode one :for each Traverse Map Of key value
for(String key : map.keySet()){
Integer value = map.get(key);
System.out.println(key + "=' =value);
}
Mode two :for each At the same time through key and value
for(Map.Entry<String,Integer> entry : map.entrySet()){
String key = entry.getKey();
Integer value = entry.getValue();
System.out.println(key + "=" + value):
}
Queue queue (FIFO)
Mode one : for each Traverse the queue
for(String s : queue){
System.out.println(s);
}
Mode two :iterator Iterator traverses queue
String item = null;
while((item = queue.poll()) != null){
System.out.println(item);
}
Deque deque
iterator Iterator traversal
String item = null;
while((item = deque.poll.set()) != null){
System.out.println(item);
}
Stack Stack (LIFO)
while(!stack.isEmpty()){
System.out.println(stack.poll());
}
版权声明
本文为[[email protected] Yummy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060916020059.html
边栏推荐
- Dark chain lock (lca+ difference on tree)
- GNSS positioning accuracy index calculation
- Music playback (toggle & playerprefs)
- RTKLIB: demo5 b34f. 1 vs b33
- Experience summary of autumn recruitment of state-owned enterprises
- TYUT太原理工大学2022数据库之关系代数小题
- Edit distance (multi-source BFS)
- 抽象类和接口
- 4.30动态内存分配笔记
- Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
猜你喜欢
Common method signatures and meanings of Iterable, collection and list
MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
Alibaba cloud microservices (IV) service mesh overview and instance istio
继承和多态(下)
TYUT太原理工大学2022数据库之关系代数小题
Fairygui bar subfamily (scroll bar, slider, progress bar)
XV Function definition and call
12 excel charts and arrays
Interview Essentials: talk about the various implementations of distributed locks!
Music playback (toggle & playerprefs)
随机推荐
Sharing ideas of on-chip transplantation based on rtklib source code
Wechat applet development experience
String类
How to ensure data consistency between MySQL and redis?
Tyut Taiyuan University of technology 2022 introduction to software engineering examination question outline
十分鐘徹底掌握緩存擊穿、緩存穿透、緩存雪崩
TYUT太原理工大学2022软工导论大题汇总
[rtklib 2.4.3 B34] version update introduction I
MySQL backup -- common errors in xtrabackup backup
162. Find peak - binary search
FileInputStream和BufferedInputStream的比较
初识C语言(上)
TYUT太原理工大学2022数据库大题之E-R图转关系模式
Smart classroom solution and mobile teaching concept description
MySQL Database Constraints
Tyut Taiyuan University of technology 2022 introduction to software engineering summary
Dark chain lock (lca+ difference on tree)
Role movement in the first person perspective
记录:newInstance()过时的代替方法
【快趁你舍友打游戏,来看道题吧】