前言
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$ |
| } |
| |
| 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)
21. psf(public static final)
22. psfi(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.out.printf("$END$"); |
30. sout(Prints a string to System.out)
| System.out.println($END$); |
31. soutc(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)
36. thr(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(); |
| } |
| |
学无止境,谦卑而行.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
2018-12-24 json_decode()相关报错
2018-12-24 wamp下var_dump()相关问题
2018-12-24 es6箭头函数内部判断
2018-12-24 Json数组对象取值