IDEA编写快捷生成代码
阅读原文时间:2023年07月08日阅读:3

转载于:https://www.jianshu.com/p/029c2de5c612

1. psvm

//生成main方法:  
 public static void main(String\[\] args) {}
  1. sout

    //生成打印输出:
    System.out.println();

3. "abc".sout

//生成打印字符串:
System.out.println("adc");

  1. "abc".format

    //生成字符串格式化:
    String.format("abc", )

//如List或者Array: List list = new ArrayList<>(); 

  1. itli

    //生成for循环
    for (int i = 0; i < list.size(); i++) {
    String s = list.get(i);
    }

6. itco

// 生成Collection迭代器
for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
String next = iterator.next();
}

7. iter

///生成增强for循环
for (String s : list) {
}

8.iten

///生成 enumeration遍历
while (enumeration.hasMoreElements()) {
Object nextElement = enumeration.nextElement();
}

9. itar

  ///生成数组for循环  
  int\[\] array = {1,2,3,4,5};  
  for (int i = 0; i < array.length; i++) {  
      int i1 = array\[i\];  
  }
  1. itit

    ///生成迭代器 iterator
    Iterator iterator = list.iterator();
    while (iterator.hasNext()) {
    Object next = iterator.next();
    }

  2. ittok

    //ittok 生成String token遍历
    for (StringTokenizer stringTokenizer = new StringTokenizer(APP_NAME); stringTokenizer.hasMoreTokens(); ) {
    String s = stringTokenizer.nextToken();
    }

  3. itws

    //生成Axis2 web service调用
    try {
    MyServiceLocator locator = new MyServiceLocator();
    Activator service = locator.get();
    // If authorization is required
    //((MyService_Soap_BindingStub)service).setUsername("user3");
    //((MyService_Soap_BindingStub)service).setPassword("pass3");
    // invoke business method
    service.businessMethod();
    } catch (javax.xml.rpc.ServiceException ex) {
    ex.printStackTrace();
    } catch (java.rmi.RemoteException ex) {
    ex.printStackTrace();
    }

13 .try 如:"abc".try

//生成try…..catch
try {
"abc"
} catch (Exception e) {
e.printStackTrace();
}

  1. ifn

    //生成判断是否为空
    if (list == null) {
    }

15. inn

///生成判断是否不为空  
 if (list != null) {  
 }
  1. fori

    //生成简单for循环
    for (int i = 0; i < ; i++) {
    }

17_._ inst

//生成是否是该对象引用
if (list instanceof Object) {
Object o = (Object) list;
}

18.psf

///生成 共有 静态最终的
public static final

  1. psfi

    ///生成 共有 静态最终的 int
    public static final int

20.psfs

///生成 共有 静态最终的 String
public static final String