前言
IDEA中一些JAVA的快捷语法,这里记录下
内容
🥙 查看快捷语法
ctrl+alt+s
->live
->java
🍔 现有快捷语法
1. C(Surround with Callable)
java.util.concurrent.Callable<$RET$> callable = new java.util.concurrent.Callable<$RET$>() { public $RET$ call() throws Exception { $SELECTION$ $END$ } };
2. fori(Create iteration loop)
for(int $INDEX$ = 0; $INDEX$ < $LIMIT$; $INDEX$++) { $END$ }
3. geti(Inserts singleton method getInstance)
public static $CLASS_NAME$ getInstance() { return $VALUE$; }
4. l(Iterate Iterable or array)
for ($ELEMENT_TYPE$ $VAR$ : $SELECTION$) { $END$ }
5. ifn(Inserts 'if null' statement)
if ($VAR$ == null) { $END$ }
6. inn(Inserts 'if not null' statement)
if ($VAR$ != null) { $END$ }
7. inst(Checks object type with instanceof and down-casts it)
if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }
8. itar(Iterate elements of array)
for(int $INDEX$ = 0; $INDEX$ < $ARRAY$.length; $INDEX$++) { $ELEMENT_TYPE$ $VAR$ = $ARRAY$[$INDEX$]; $END$ }
9. itco(Iterate elements of java.util.Collection)
for($ITER_TYPE$ $ITER$ = $COLLECTION$.iterator(); $ITER$.hasNext(); ) { $ELEMENT_TYPE$ $VAR$ =$CAST$ $ITER$.next(); $END$ }
10. iten(Iterate java.util.Enumeration)
while($ENUM$.hasMoreElements()){ $TYPE$ $VAR$ = $CAST$ $ENUM$.nextElement(); $END$ }
11. iter(Iterate Iterable or array)
for ($ELEMENT_TYPE$ $VAR$ : $ITERABLE_TYPE$) { $END$ }
12. itit(Iterate java.util.Iterator)
while($ITER$.hasNext()){ $TYPE$ $VAR$ = $CAST$ $ITER$.next(); $END$ }
13. itli(Iterate elements of java.util.List)
for (int $INDEX$ = 0; $INDEX$ < $LIST$.size(); $INDEX$++) { $ELEMENT_TYPE$ $VAR$ = $CAST$ $LIST$.get($INDEX$); $END$ }
14. ittok(Iterate tokens from String)
for (java.util.StringTokenizer $TOKENIZER$ = new java.util.StringTokenizer($STRING$); $TOKENIZER$.hasMoreTokens(); ) { String $VAR$ = $TOKENIZER_COPY$.nextToken(); $END$ }
15. lazy(Performs lazy initialization)
if ($VAR$ == null) { $VAR$ = new $TYPE$($END$); }
16. lst(Fetches last element of an array)
$ARRAY$[$ARRAY$.length - 1]
17. main(main() method declaration)
public static void main(String[] args){ $END$ }
18. mn(Sets lesser value to a variable)
$VAR$ = Math.min($VAR$, $END$);
19. mx(Sets greater value to a variable)
$VAR$ = Math.max($VAR$, $END$);
20. prsf(private static final)
private static final
21. psf(public static final)
public static final
22. psfi(public static final int)
public static final int
23. psfs(public static final String )
public static final String
24. psvm(main() method declaration)
public static void main(String[] args){ $END$ }
25. ritar(Iterate elements of array in reverse order)
for(int $INDEX$ = $ARRAY$.length - 1; $INDEX$ >= 0; $INDEX$--) { $ELEMENT_TYPE$ $VAR$ = $ARRAY$[$INDEX$]; $END$ }
26. RL(Surround with ReadWriteLock.readLock)
$LOCK$.readLock().lock(); try { $SELECTION$ } finally { $LOCK$.readLock().unlock(); }
27. serr(Prints a string to System.err)
System.err.println($END$);
28. serrc(System.err::println)
System.err::println
29. souf(Prints a formatted string to System.out)
System.out.printf("$END$");
30. sout(Prints a string to System.out)
System.out.println($END$);
31. soutc(System.out::println)
System.out::println
32. soutm(Prints current class and method names to System.out)
System.out.println("$CLASS_NAME$.$METHOD_NAME$");
33. soutp(Prints method parameter names and values to System.out)
System.out.println($FORMAT$);
34. soutv(Prints a value to System.out)
System.out.println("$EXPR_COPY$ = " + $EXPR$);
35. St(String)
String
36. thr(throw new)
throw new
37. toar(Stores elements of java.util.Collection into array)
$COLLECTION$.toArray(new $COMPONENT_TYPE$[0])$END$
38. WL(Surround with ReadWriteLock.writeLock)
$LOCK$.writeLock().lock(); try { $SELECTION$ } finally { $LOCK$.writeLock().unlock(); }
学无止境,谦卑而行.