IntelliJ IDEA使用技巧--Live Templates 及Postfix

  • 常用Live Templates

模板

说明

sout
System.out.println($END$);
soutv
System.out.println("$EXPR_COPY$ = " + $EXPR$);

main

psvm

public static void main(String[] args){
  $END$
}

说明: 对于普通模板输入后,回车/tab键即可;对于环绕的模板,选中代码,再使用快捷键: ctrl+Alt+J,再选择对应的模板.

位置:

  1. 快捷键:Ctrl + Shift + A,打开搜索框;输入“live templates”
  2. 模板界面,可以查看预定义模板及进行自定义模板
  3. 预定义模板
  4. 自定义模板,根据各自需要进行定义使用.

  • 常用Postfix

postfix说明
varIntroduces variable for expression.定义变量

try

Insert statement in try-catch block.
soutvCreates System.out.println with a description of printed value call.
soutCreates System.out.println call.
returnReturns value from containing method.

for

iter

Iterates over enumerable collection.
foriIterates with index over collection.
ifChecks boolean expression to be 'true'.
lambdaSurrounds expression with lambda.
optCreates Optional object.
whileIterating while boolean statement is 'true'.
switchProduces switch over integral/enum/string values.
synchronizedProduces synchronization statement.

 

说明: 对应的方法/参数后.postfix回车,即可.如: m().try --->

try {
    m();
  } catch(CheckedException e) {
    e.printStackTrace();
  }

位置:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值