idea部分常用模板
—2020年06月09日
psvm(main方法)
//模板一:psvm
public static void main(String[] args) {
}
sout(输出)
//模板二: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循环)
//模板三: 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循环)
//模板四: 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)
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(类常量)
//模板六: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";
自定义模板
打开设置
创建分组
创建模板
说明:
步骤11:设置模板调用字符
步骤12:此模板的描述
步骤13:模板内容
/**
*$VAR1$
*/
private int $VAR2$;
$END$
步骤14:设置模板应用范围
选择模板应用范围
我们选择Java
选择之后点击OK,应用模板
结果
//自定义模板 pri
/**
*自定义模板测试
*/
private int id;
附录
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) {
}
}
}