IntelliJ IDEA(快捷键):快速生成各种for循环
原帖:https://blog.csdn.net/Soinice/article/details/83505198
为了防止删除备份的。
iterations 快捷键
Live Templates
其实下面介绍的所有for循环都在live templates里面,当然可以自定义:
迭代器for循环
iter
Iterate iterable | Array in J2SDK 5 syntax
-
for (String arg : args) {
-
-
}
-
itar
Iterate elements of array
-
for (int j = 0; j < args.length; j++) {
-
String arg = args[j];
-
-
}
-
itco
Iterate elements of java.util.Collection
-
for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) {
-
Object next = iterator.next();
-
-
}
-
iten
Iterate java.util.Enumeration
-
while (enumeration.hasMoreElements()) {
-
Object nextElement = enumeration.nextElement();
-
-
}
-
itit
Iterate java.util.Iterator
-
while (iterator.hasNext()) {
-
Object next = iterator.next();
-
-
}
-
itli
Iterate elements of java.util.List
-
for (int j = 0; j < list.size(); j++) {
-
Object o = list.get(j);
-
-
}
-
ittok
Iterate tokens from String
-
for (StringTokenizer stringTokenizer = new StringTokenizer(); stringTokenizer.hasMoreTokens(); ) {
-
String s = stringTokenizer.nextToken();
-
-
}
-
itve
Iterate elements of java.util.Vector
-
for (int j = 0; j < vector.size(); j++) {
-
Object elementAt = vector.elementAt(j);
-
-
}
-
以上快捷键在IDEA中输入it后,在IDEA的代码提示中均可以找到。
普通for循环
fori
create iteration loop
-
for (int j = 0; j < ; j++) {
-
-
}
-
foreach
create a for each loop
-
for (:
-
) {
-
-
}
-
最后附上最新全IDEA快捷键列表
ReferenceCard
ReferenceCardForMac