当前位置:网站首页>Intelij idea efficient skills (II)
Intelij idea efficient skills (II)
2022-06-21 21:54:00 【crysw】
1. Introduce
idea Is the tool we use most , So the purpose of this article is to lead you to use idea.
idea There is a special awesome function in :live template( Template function ), You can create a piece of code as a template , Then define a shorter name for the template , Then enter the name of the template in the code tab perhaps enter key , Template code snippets can be instantaneously introduced into the current code , Greatly improved the development efficiency . Here are some common template methods .
2. frequently-used live tempalte
2.1 main Method
psvm+Enter key : Output main Method
public static void main(String[] args) {
}
2.2 Output if block
boolean Variable .if+Enter key : Output if block
for example : flag.if+Enter key
boolean flag = true;
if (flag) {
}
2.3 Output is not if block
boolean Variable .else+Enter key : Output is not if block
for example : flag.else+Enter key
boolean flag = true;
if (!flag) {
}
2.4 Output for loop
fori+Enter key : Output for loop
for (int i = 0; i < ; i++) {
}
list Variable .fori+Enter key : Output for loop
List<String> list = Arrays.asList("1","2","3");
for (int i = 0; i < list.size(); i++) {
}
2.5 Output for Reverse cycle
list Variable .forr+Enter key : Output for Reverse cycle
List<String> list = Arrays.asList("1","2","3");
for (int i = list.size() - 1; i >= 0; i--) {
}
2.6 Output foreach loop
list Variable .for+Enter key : Output foreach loop
list.for+Enter key
Output results :
List<String> list = Arrays.asList("1","2","3");
for (String s : list) {
}
2.7 Output while loop
boolean Variable .while+Enter key , Output while loop
for example : flag.while+Enter key , Output
boolean flag = true;
while (flag) {
}
2.8 Quickly create an object
object .var+Enter key : Quickly create an object
such as :“ Passerby ”.var+Enter key , Output
String s = " Passerby ";
new String().var+Enter key , Output
String s = new String();
2.9 Quickly return a value in a method
Variable .return+Enter key : Quickly return a value in a method
public String getName(){
" Passerby ".return+Enter key
}
Output results :
public String getName(){
return " Passerby ";
}
2.10 Quick output console print statements
sout+Enter key : Fast output
System.out.println();
Print out variables quickly , “ Passerby ”.sout+Enter key , Output
System.out.println(" Passerby ");
2.11 Fast output try…catch block
Code tail .try+Enter key : Fast output try…catch block
int i = 10;.try+Enter key
Output results :
try {
int i = 10;
} catch (Exception e) {
e.printStackTrace();
}
2.12 Define static variables
Class prsf+Enter key , Output private static variables
private static final
Class psf+Enter key , Output public static variables
public static final
Class psfi+Enter key , Output int Public static variables of type
public static final int
Class psfs+Enter key , Output String Public static variables of type
public static final String
2.13 Quickly throw an exception
Method thr+Enter key , Output
throw new
3. Customize live template
idea Some commonly used , But sometimes we also want to customize some of our common templates , So how to operate ?
Open Settings File->Settings->Live template , Add a group . Click... As shown below "+", choice "Template Group", The group name is tcf Well , You can name it as you like
stay tcf Add a template under the group tcf, The operation is as follows :
Set up tcf Template information , What I'm adding here is try-catch-finally Code block ;
- Abbreviation( Indent name ): That is, after the code input pssd Press the shortcut key to generate private static String var
- Edit variables( Edit and write ): Edit variables , Including the order , Variable function, etc , See notes below for details
- Description( notes ): Note template function
- Template text( Template body ):x x As a variable ,END Is a self-contained variable , That is, where the last cursor stays
- Applicable( Range of application ): Indicate what file and under what circumstances . Generally, it is checked by default java Can
- options( Shortcut key ): The input pssd Then press Enter still Tab Generate template . Authors generally use Tab key , On the one hand, it is to prevent conflicts with the built-in template , On the other hand, with shell Shortcut keys one to
- Reformate According to Style: Automatic code formatting . If you do not check the code, it will not be indented and wrapped automatically
When entering... In the code "tcf+Enter key ", The following code appears instantly , Is it really cool .
try {
} catch (Exception e) {
} finally {
}
Personal blog
Welcome to my personal blog : https://www.crystalblog.xyz/
Alternate address : https://wang-qz.gitee.io/crystal-blog/
边栏推荐
- 杰理之获取当前音频文件(长)文件名和当前(长)文件夹名【篇】
- OpenJudge NOI 1.13 45:十进制到八进制
- matplotlib plt. Details of subplots()
- When Jerry made Bluetooth transmission, when he modified stereo to mono differential output, there was a jam sound at the receiving end [chapter]
- #16迭代器经典案例
- How to check the duplicate of an English paper?
- AWS CloudWatch
- Jerizhi, processing method for prompting chip information mismatch and error code 10 [chapter]
- Mendeley installation, configuration and use
- C语言数组与指针练习题(原题+解析+原码)
猜你喜欢
随机推荐
ACM. HJ35 蛇形矩阵 ●
Xr34082a high efficiency boost dc/dc regulator IC
搭建Eureka-Server集群
杰理之蓝牙发射器的搜索设备的时间修改方法【篇】
JS中的构造函数(重点)
[yolov5] opencv450 loads onnx for reasoning GPU acceleration
What is the standard format for writing citations in academic papers?
ACM. Hj35 serpentine matrix ●
Jinghe integration has passed the registration: it plans to raise 9.5 billion yuan. Hefei Construction Investment and Midea are shareholders
prototype扩展:实现对象继承
Tkinter drawing component (29) -- Radio Group Control
There is no sound solution to the loopback when jerryzhi launches Bluetooth [chapter]
K - Clairewd’s message HDU - 4300 (EXKMP)
Fm5012d small fan integrated IC scheme
Installing component and package libraries in Ad
#16迭代器经典案例
Go language unit test basics from getting started to giving up
Caricature scientifique | Vous pouvez apprendre l'EEG en regardant les images. Voulez - vous essayer?
Go单元测试对数据库CRUD进行Mock测试
ARP protocol and ARP attack








