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

    1. for (String arg : args) {
    2.  
    3. }

itar

Iterate elements of array

    1. for (int j = 0; j < args.length; j++) {
    2. String arg = args[j];
    3.  
    4. }

itco

Iterate elements of java.util.Collection

    1. for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) {
    2. Object next = iterator.next();
    3.  
    4. }

iten

Iterate java.util.Enumeration

    1. while (enumeration.hasMoreElements()) {
    2. Object nextElement = enumeration.nextElement();
    3.  
    4. }

itit

Iterate java.util.Iterator

    1. while (iterator.hasNext()) {
    2. Object next = iterator.next();
    3.  
    4. }

itli

Iterate elements of java.util.List

    1. for (int j = 0; j < list.size(); j++) {
    2. Object o = list.get(j);
    3.  
    4. }

ittok

Iterate tokens from String

    1. for (StringTokenizer stringTokenizer = new StringTokenizer(); stringTokenizer.hasMoreTokens(); ) {
    2. String s = stringTokenizer.nextToken();
    3.  
    4. }

itve

Iterate elements of java.util.Vector

    1. for (int j = 0; j < vector.size(); j++) {
    2. Object elementAt = vector.elementAt(j);
    3.  
    4. }

以上快捷键在IDEA中输入it后,在IDEA的代码提示中均可以找到。

普通for循环

fori

create iteration loop 

    1. for (int j = 0; j < ; j++) {
    2.  
    3. }

foreach

create a for each loop

    1. for (:
    2. ) {
    3.  
    4. }

最后附上最新全IDEA快捷键列表

ReferenceCard

ReferenceCardForMac

posted @ 2019-03-06 22:59  梧桐将秋色  阅读(63945)  评论(2编辑  收藏  举报