Here follows a short list of some IntelliJ IDEA useful shortcuts and tips to improve your productivity whilst coding Java.
Type Alt + Insert to open the code generation dropbox, then type:
Enter directly, then Up and Ctrl + Enter for no-arg constructor.Enter directly, then Ctrl + A to select all of the arguments.get for generating only getters, then Ctrl + A to select’em all.set for generating only setters, then Ctrl + A to select’em all.gas for generating both getters and setters, then Ctrl + A to select’em all.to for generating the toString method.ha or eq for equals and hashCode, then manually pick your fields or just hit Enter three times.Type the following inside of your class then press Enter to automatically generate the desired snippet:
psvm for a public static void main method.sout for an empty System.out.println() call.Ctrl + Alt + L.Ctrl + Alt + O.Ctrl + Alt + V.Ctrl + N.Ctrl + Shift + N.Shift, it opens a dialog where you can type things like format and the IDE will search for files and actions containing format in its name.Ctrl + Shift + F9 to compile a single class.Ctrl + Shift + F10 to run the main method.When you run a main method of a class within your project, it invokes the Build process of the given project. To avoid that:
Edit Configurations...;Application -> Class-you-want-to-run, remove the step Build at the bottom of the window by clicking on the red minus button and click OK;Ctrl + Shift + F9 to compile it;Ctrl + Shift + F10 to run your main method.If you still don’t use Lombok, the following templates are useful for auto generating code and javadocs. The highlighted lines are the lines I’ve changed from the original templates.
#if($field.modifierStatic)
static ##
#end
$field.type ##
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($field.boolean && $field.primitive)
is##
#else
get##
#end
${name}() {
return $field.name;
} #set($paramName = $helper.getParamName($field, $project))
#if($field.modifierStatic)
static ##
#end
void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
#if ($field.name == $paramName)
#if (!$field.modifierStatic)
this.##
#else
$classname.##
#end
#end
$field.name = $paramName;
} I will keep updating this list as soon as I discover new features and shortcuts.
Cya!
This guide will show you how to create a Python function decorator with a few…
This guide will show you how to fix the error Got permission denied while trying…
This guide will show you how to create a Python virtual environment on Intellij IDEA…
This tutorial will quickly show you how to to find and kill processes on Linux,…
This guide shows a possible solution for Python error Relocation R_X86_64_PC32 against symbol can not…
I condensed below a cheat sheet of Kubernetes useful commands. I will keep updating this…