总结
在IntelliJ IDEA中可以输入快捷关键词,生成大段的循环代码块,接下来让我们逐一演示
for循环
输入itar快捷生产array for代码块
itar
-------------------------------
for (int i = 0; i < array.length; i++) {
= array[i];
}
输入itco生成
itco
-------------------------------
for (Iterator<Map<String, String>> iterator = show.iterator(); iterator.hasNext(); ) {
Map<String, String> next = iterator.next();
}
输入iter生成
iter
-------------------------------
for (Map<String, String> stringStringMap : show) {
}
输入itli生成
itli
-------------------------------
for (int i = 0; i < show.size(); i++) {
Map<String, String> stringStringMap = show.get(i);
}
输入ittok生成
ittok
-------------------------------
for (StringTokenizer stringTokenizer = new StringTokenizer(sql); stringTokenizer.hasMoreTokens(); ) {
String s = stringTokenizer.nextToken();
}
while循环
输入iten生成
iten
-------------------------------
while (enumeration.hasMoreElements()) {
Object nextElement = enumeration.nextElement();
}
输入itit生成
itit
-------------------------------
while (iterator.hasNext()) {
Object next = iterator.next();
}
try 循环
输入itaws生成
itaws
-------------------------------
try {
MyServiceStub stub = new MyServiceStub();
stub.sayHelloWorldFrom();
} catch (Exception ex) {
ex.printStackTrace();
}
输入itws生成
itws
-------------------------------
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();
}