部分常用模板

psvm(main方法)

1
2
3
4
//模板一:psvm
public static void main(String[] args) {

}

sout(输出)

1
2
3
4
5
6
7
8
9
10
11
12
13
//模板二:sout
System.out.println("hello!");
//变形: soutp / soutm /soutv / xxx.sout
// soutp
System.out.println("args = [" + args + "]");
// soutm
System.out.println("TempletsTest.main");
// soutv
int num=10;
int num2=20;
System.out.println("num2 = " + num2);
System.out.println("num = " + num);
System.out.println(num);

fori(for循环)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//模板三: fori
String[] arr= new String[]{"Tom","Jerry","Meimei","Lilei"};
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
//变形 iter
for (String s : arr) {
System.out.println(s);
}
//变形 itar
for (int i = 0; i < arr.length; i++) {
String s = arr[i];
System.out.println(s);
}

list.for(List循环)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//模板四: list.for
ArrayList list=new ArrayList();
list.add("hello");
list.add(123);
list.add(456);
for (Object o : list) {

}
//变形: list.fori
for (int i = 0; i < list.size(); i++) {

}
//变形: list.forr 倒叙遍历
for (int i = list.size() - 1; i >= 0; i--) {

}

ifn(判断NULL)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 		ArrayList list=new ArrayList();
list.add("hello");
list.add(123);
list.add(456);
//模板五:ifn
if (list == null) {

}
//变形:inn
if (list != null) {

}
//变形:xxx.null
if (list == null) {

}
//变形:xxx.nn
if (list != null) {

}

prsf(类常量)

1
2
3
4
5
6
7
8
9
//模板六:prsf 可生成 private static final
private static final String sss=new String();

//变形:psf
public static final int NUM1 = 9;
//变形:psfi
public static final int NUM2=10;
//变形:psfs
public static final String ST1="hello";

自定义模板

打开设置

set

创建分组

group

createGroup

创建模板

templets

createTemplets

说明:

​ 步骤11:设置模板调用字符

​ 步骤12:此模板的描述

​ 步骤13:模板内容

1
2
3
4
5
/**
*$VAR1$
*/
private int $VAR2$;
$END$

​ 步骤14:设置模板应用范围

选择模板应用范围

我们选择Java

select

选择之后点击OK,应用模板

结果

result

result

1
2
3
4
5
//自定义模板 pri
/**
*自定义模板测试
*/
private int id;

附录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

import java.util.ArrayList;

public class TempletsTest {
//自定义模板 pri
/**
*自定义模板测试
*/
private int id;

//模板六:prsf 可生成 private static final
private static final String sss=new String();

//变形:psf
public static final int NUM1 = 9;
//变形:psfi
public static final int NUM2=10;
//变形:psfs
public static final String ST1="hello";


//模板一:psvm
public static void main(String[] args) {
//模板二:sout
System.out.println("hello!");
//变形: soutp / soutm /soutv / xxx.sout
// soutp
System.out.println("args = [" + args + "]");
// soutm
System.out.println("TempletsTest.main");
// soutv
int num=10;
int num2=20;
System.out.println("num2 = " + num2);
System.out.println("num = " + num);
System.out.println(num);

//模板三: fori
String[] arr= new String[]{"Tom","Jerry","Meimei","Lilei"};
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
//变形 iter
for (String s : arr) {
System.out.println(s);
}
//变形 itar
for (int i = 0; i < arr.length; i++) {
String s = arr[i];
System.out.println(s);
}

//模板四: list.for
ArrayList list=new ArrayList();
list.add("hello");
list.add(123);
list.add(456);
for (Object o : list) {

}
//变形: list.fori
for (int i = 0; i < list.size(); i++) {

}
//变形: list.forr 倒叙遍历
for (int i = list.size() - 1; i >= 0; i--) {

}

//模板五:ifn
if (list == null) {

}
//变形:inn
if (list != null) {

}
//变形:xxx.null
if (list == null) {

}
//变形:xxx.nn
if (list != null) {

}



}
}

最后更新: 2020年06月11日 09:49

原始链接: http://ligangit.com/2020/06/09/IDEA部分模板/

× 请我吃糖~
打赏二维码