idea的一些常用live templates:
这些live templates的设置在IDE-SETTING — Live Templates中.
快速查看live templates
ctrl+j
使用方法是:[缩减字母] + tab(默认是tab键,可以改成其他的space或者是enter)
个人比较常用的有:
sout:输出system.out
——————————————–
System.out.println();
psvm:出现main方法
——————————————–
public static void main(String[] args) {
}
psfi:公开静态常量的int类型
——————————————–
public static final int
psfs:公开静态常量的String类型
——————————————–
public static final String
thr:快速抛出异常
——————————————–
throw new
geti:静态的获取实例方法
——————————————–
public static IdeaTest getInstance() {
return null;
}
ifn:出现一个空的代码块
——————————————–
if (i == null) {
}
inn:在方法中针对参数出现一个 空判断的代码块
——————————————–
if (i != null) {
}
lazy:延迟初始化的代码块
——————————————–
if (i == null) {
i = new Integer(0);
}
RL:出现一个读锁的代码块
——————————————–
.readLock().lock();
try {
} finally {
.readLock().unlock();
}
WL:出现一个写锁的代码块
——————————————–
.writeLock().lock();
try {
} finally {
.writeLock().unlock();
}
fori:出现一个有下标的for循环
——————————————–
for (int j = 0; j < ; j++) {
}
iter:foreach的循环,还有一个更简单的,直接I就可以。
——————————————–
for (Object o : ) {
}
0 条评论。