idea的常用代码模板
程序员文章站
2022-06-13 18:18:22
...
**
idea的常用代码模板
**
/**
* 1. IDEA中代码模板所处的位置:settings - Editor - Live Templates / Postfix Completion
* 2. 常用的模板
*/
public class TemplatesTest {
//模板六: prsf:可生成 private static final
private static final Customer CUST = new Customer();
//变形:psf
public static final int NUM = 1;
//变形:psfi
public static final int NUM2 = 2;
//变形:psfs
public static final String NATION = "china";
//模板一:psvm
public static void main(String[] args) {
//模板二:sout
System.out.println("hello!");
//变形:soutp / soutm / soutv / xxx.sout
System.out.println("args = [" + args + "]");
System.out.println("TemplatesTest.main");
int num1 = 10;
System.out.println("num1 = " + num1);
int num2 = 20;
System.out.println("num2 = " + num2);
System.out.println(num1);
//模板三:fori
String[] arr = new String[]{"Tom","Jerry","HanMeimei","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(123);
list.add(345);
list.add(567);
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--) {
}
}
public void method(){
System.out.println("TemplatesTest.method");
ArrayList list = new ArrayList();
list.add(123);
list.add(345);
list.add(567);
//模板五:ifn
if (list == null) {
}
//变形:inn
if (list != null) {
}
//变形:xxx.nn / xxx.null
if (list == null) {
}
if (list != null) {
}
}
推荐阅读
-
解决idea 拉取代码出现的 “ Сannot Run Git Cannot identify version of git executable: no response“的问题
-
Jquery实现的一种常用高亮效果示例代码_jquery
-
归纳总结PHP中常用的10类代码
-
值得收藏的iOS开发常用代码块
-
springboot用thymeleaf模板的paginate分页完整代码
-
C#字符串的常用操作工具类代码分享
-
值得收藏的iOS开发常用代码块
-
总结ASP.NET C#中经常用到的13个JS脚本代码
-
Vue模板语法中数据绑定的实例代码
-
详述IntelliJ IDEA提交代码前的 Code Analysis 机制(小结)