IDEA 常用的模板
阿新 • • 發佈:2018-11-16
import java.util.ArrayList;
import java.util.List;
/**
* 1. IDEA 中程式碼模板所處的位置 Settings -> live Templates
* /Postfix Completion
* 2. 常用的模板
*/
public class TestSettings {
//模板6 prsf 可生成 private static fianl boolean;
private static final boolean flag = false;
//變形 psf 可生成 public static final
public static final int num = 1;
//變形 psfi public static final int
public static final int num2 = 2;
//變形 psfs public static final String
public static final String s = "China";
//模板一 psmv
public static void main(String[] args) {
//模板二 sout
System.out.println ("hello");
//變形 soutp / soutm / soutv/ xxx.sout
System.out.println("args = [" + args + "]");
System.out.println("TestSettings.main");
int num = 10,num2 = 20;
System.out.println("num2 = " + num2);
System.out.println(num);
//模板三 fori
String[] arr = new String[]{"hanmeimei","lilei","angek","安琪"};
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];
}
//模板四 list.for
List<Integer> list = new ArrayList<>();
for (Integer integer : list) {
System.out.println("integer = " + integer);
}
//變形 list.fori list.forr(逆序)
//模板五 ifn
if (list == null) {
}
//變形 inn
if (list != null) {
}
//變形 xxx.nn / xxx.null
}
}