Java shortcut keys

Source: Internet
Author: User

Common shortcut keys
Shift+enter: Inserts a new row below the current line, which is value when the cursor is in the middle of a line

Ctrl+shift+enter: Inserting a new row on the current line

Ctrl+d: Delete entire row

Ctrl+alt+j: Merge line, equivalent to J in VI

Ctrl+alt+up/down: Copy rows up/down

Alt+up/down: Line up/down move

F2: Show Tip

Ctrl+shift+f:format, formatting documents

Ctrl+alt+/:word Auto-complete

Ctrl+1: Fast fix (quick fix)

alt+/: Content Assist, for activating input templates, etc.

Input template (Java)
How to use: Enter the name of the template, and then use the alt+/shortcut key

Cast

${type} ${new_name} = (${type}) ${name};

Catch:

catch (${exception} ${exception_variable_name}) {
${cursor}//${todo}: Handle exception
}

Do

do {
${line_selection}${cursor}
} while (${condition:var (Boolean)});

Else

else {
${cursor}
}

ElseIf

else if (${condition:var (Boolean)}) {
${cursor}
}

For

for (int ${index} = 0; ${index} < ${array}.length; ${index}++) {
${line_selection}${cursor}
}

Foreach:

For (${iterable_type} ${iterable_element}: ${iterable}) {
${cursor}
}

If

if (${condition:var (Boolean)}) {
${line_selection}${cursor}
}

instanceof:

if (${name:var} instanceof ${type}) {
${type} ${new_name} = (${type}) ${name};
${cursor}
}

Main

public static void Main (string[] args) {
${cursor}
}

New

${type} ${name} = new ${type} (${arguments});

Private_method:

Private ${return_type} ${name} (${}) {
${cursor}
}

Private_static_method:

private static ${return_type} ${name} (${}) {
${cursor}
}

Protected_method:

Protected ${return_type} ${name} (${}) {
${cursor}
}

Public_method:

Public ${return_type} ${name} (${}) {
${cursor}
}

Runnable

New Runnable () {
public void Run () {
${line_selection}
}
}

Static_final:

${visibility:link (public,protected,private)} static final ${type:link (String,int)} ${name};

Switch

Switch (${key}) {
Case ${value}:
${cursor}
Break

Default
Break
}

Synchronized

Synchronized (${mutex:var}) {
${line_selection}
}

Syserr:

System.err.println (${word_selection}${}); ${cursor}


Sysout:

System.out.println (${word_selection}${}); ${cursor}

Systrace:

System.out.println ("${enclosing_type}.${enclosing_method} ()");

Test

public void Test${name} () throws Exception {
${cursor}
}

ToArray

(${type:elemtype (collection)}[]) ${collection}.toarray (new ${type}[${collection}.size ()))

Try

try {
${line_selection}${cursor}
} catch (${exception} ${exception_variable_name}) {
${todo}: Handle exception
}

While

while (${en:var (java.util.Enumeration)}.hasmoreelements ()) {
${type:argtype (en)} ${elem:newname (type)} = (${type}) ${en}.nextelement ();
${cursor}
}

Java shortcut keys

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.