IntelliJ IDEA使用指南
1.代码模板
package com.test;
import java.util.ArrayList;
import java.util.Arrays;
/**
* 模板的使用
* IDEA代码模板所处的位置:
* (1)settings - Editor - Live Template/Postfix Completion
* 常用的模板的位置:Live Template:(iteration other output plain)
* @author:XuBing
* @data:2021/8/12——10:01 下午
*/
public class Templates {
//module 6: transformation prsf
private static final String a="aaa";
//module 6:psf psfi psfs
public static final String b="bbb";
public static final int c=1;
public static final String d="ddd";
//module 1:psvm main调出main方法
public static void main(String[] args) {
//module 2:sout
System.out.println("hello");
//模板2:变形 soutp/soutm/soutv/xxx.sout
System.out.println("args = " + Arrays.deepToString(args));
System.out.println("Templates.main");
System.out.println("args = " + args);
System.out.println(args);
//module 3:fori
String []arr=new String[]{"A","B","c"};
for (int i = 0; i < arr.length ; i++) {
}
//transformation:iter
for (String s : arr) {
}
//transformation:itar
for (int i = 0; i < arr.length; i++) {
String s = arr[i];
}
//module 4:list.for
ArrayList<String> list = new ArrayList<>();
for (String s : list) {
}
//module 4:transformation list.fori
for (int i = 0; i < list.size(); i++) {
}
//module 4:transformation list.forr
for (int i = list.size() - 1; i >= 0; i--) {
System.out.println("倒叙遍历");
}
}
public void method(){
//module 5: ifn
ArrayList<String> list = new ArrayList<>();
if (list == null) {
}
//module 5:transformation: inn
if (list != null) {
}
//module 5: transformation :xxx.nn xxx.null
if (list != null) {
}
if (list == null) {
}
}
}
2.自定义代码模板
(1)自动生成无返回值方法
pvoid
public void $VAR1$() {
$VAR2$
}
(2)自定生成返回值是Map的方法
pmap
public Map $VAR1$() {
Map map = new HashMap();
$VAR2$
return map;
}
(3)自动生成private static final string
prsfs
private static final String $VAR1$ = $VAR2$;//$VAR3$
$END$
(4)自动生成private static final int
prsfi
private static final int $VAR1$ = $VAR2$;//$VAR3$
$END$