IDEA常用快速生成代码快捷键

Java 1692℃

1. psvm

//生成main方法:
public static void main(String[] args) {}

2. sout

//生成打印输出:
System.out.println();

3. “abc”.sout

//生成打印字符串:
System.out.println("adc");

4. psf

///生成 共有 静态最终的
public static final

5. psfi

///生成 共有 静态最终的 int
public static final int

6. psfs

///生成 共有 静态最终的 String
public static final String

7.CTRL+ALT+T

//把选中的代码放在 if/while/for/try里

8. ifn

///生成判断是否为空
if (x == null) {

}

9. inn

///生成判断是否不为空
if (x != null) {

}

10. inst

///生成是否是该对象引用
if (x instanceof Object) {
    Object o = (Object) x;
}

11. fori

///生成简单for循环
for (int i = 0; i < ; i++) {
}

12. itli

//生成list的for循环
for (int i = 0; i < list.size(); i++) {
    String s = list.get(i);
}

13. itar

///生成array的for循环
int[] array = {1,2,3,4,5};
for (int i = 0; i < array.length; i++) {
    int i1 = array[i];
}

14. iter

///根据最近数组/集合生成增强for循环
for (String s : list) {
}

15. list.for

///生成指定数组增强for循环
for (String s : list) {
}

16.I

//生成空白格式增强for循环
for (Object ob : ) {

}

17. iten

///生成 enumeration遍历
while (enumeration.hasMoreElements()) {
    Object nextElement = enumeration.nextElement();
}

18. itit

///生成迭代器 iterator
while (iterator.hasNext()) {
    Object next = iterator.next();
}

19. itco

/// 生成Collection迭代器
for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
    String next = iterator.next();
}

20 .”xxx”.try

/// 生成try.....catch
try {
    "xxx"
} catch (Exception e) {
    e.printStackTrace();
}

转载请注明:零五宝典 » IDEA常用快速生成代码快捷键