Eclipse Java Code

Posted on  by admin
  • Course is Organised into 11 Steps: Experienced Eclipse Developers can give Step 0 a skip. Step 0: Eclipse Basics - Workspace & Your First Java File; Step 1: Most Important Editing Shortcuts ctrl-1 and ctrl-space; Step 2: Debugging Java Programs; Step 3: Eclipse Short Cuts; Step 4: Refactoring with Eclipse; Step 5: Code Generation with Eclipse.
  • Eclipse Code Recommenders assists Java developers in learning how to use and extend new APIs by leveraging the information hidden in the source code of existing applications and integrating the gained knowledge back into our day-to-day development tool: the Eclipse IDE.
  1. Eclipse Java Code
  2. Eclipse Java Code Formatter Xml Download
  3. Eclipse Java Code Completion Not Working
  4. Eclipse Java Code Coverage

Each code template is given a short literal. Typing the literal into the editor window and press Ctrl + Space brings up a dialog box from which a code template associated with that literal can be selected. Typing for within the body of a method in the java editor window and clicking Ctrl + space shows the code templates associated with for. In eclipse, workbench (desktop development environment) is a window instance of IDE.

EclipseEclipse java code completion
Written by Nam Ha Minh
Last Updated on 07 August 2019 Print Email
When using an IDE, you cannot be more productive without using its shortcut keys frequently as your habit. In this article, we summarize a list of shortcut keys which are useful for editing Java code in Eclipse IDE.Eclipse java code formatterNOTE:

Eclipse Java Code

Standard shortcuts are not covered, such as Ctrl + A (select all), Ctrl + Z (undo), etc.Eclipse Java Code
  1. Ctrl + D: Deletes current line.
  2. Ctrl + Delete: Deletes next word after the cursor.
  3. Ctrl + Shift + Delete: Deletes from the cursor until end of line.
  4. Ctrl + Backspace: Deletes previous word before the cursor.
  5. Shift + Ctrl + y: Changes a selection to lowercase.
  6. Shift + Ctrl + x: Changes a selection to uppercase.
  7. Alt + Up Arrow: Moves up current line (or a selected code block) by one line:
  8. Alt + Down Arrow: Moves down current line (or a selected code block) by one line:
  9. Ctrl + Alt + Up Arrow: Copies and moves up current line (or a selected code block) by one line:
  10. Ctrl + Alt + Down Arrow: Copies and moves down current line (or a selected code block) by one line:
  11. Shift + Enter: Inserts a blank line after current line, regardless where the cursor is at the current line (very different from press Enter key alone):
  12. Ctrl + Shift + Enter: works similar to the Shift + Enter, but inserts a blank line just before the current line.
  13. Ctrl + Shift + O: Organizes import statements by removing unused imports and sorts the used ones alphabetically. This shortcut also adds missing imports.
  14. Ctrl + Shift + M: Adds a single import statement for the current error due to missing import. You need to place the cursor inside the error and press this shortcut:
  15. Ctrl + Shift + F: Formats a selected block of code or a whole source file. This shortcut is very useful when you want to format messy code to Java-standard code. Note that, if nothing is selected in the editor, Eclipse applies formatting for the whole file:

  16. Ctrl + I: Corrects indentation for current line or a selected code block. This is useful as it helps you avoid manually using Tab key to correct the indentation:
  17. Ctrl + /or Ctrl + 7: Toggle single line comment. This shortcut adds single-line comment to current line or a block of code. Press again to remove comment. For example:
  18. Ctrl + Shift + /: Adds block comment to a selection.
  19. Ctrl + Shift + : Removes block comment.
  20. Alt + Shift + S: Shows context menu that lists possible actions for editing code:
    From this context menu, you can press another letter (according to the underscore letters in the names) to access the desired functions.
  21. Alt + Shift + S, R: Generates getters and setters for fields of a class. This is a very handy shortcut that helps us generate getter and setter methods quickly. The following dialog appears:
  22. Alt + Shift + S, O: Generates constructor using fields. This shortcut is very useful when you want to generate code for a constructor that takes class’ fields as its parameters. The following dialog appears:
  23. Alt + Shift + S, C: Generates Constructors from Superclass. A common example for using this shortcut is when creating a custom exception class. In this case, we need to write some constructors similar to the Exception superclass. This shortcut brings the Generate Constructors from Superclass dialog which allows us to choose the constructors to be implemented in the subclass:
  24. Alt + Shift + S, H: Generates hashCode() and equals() methods, typically for a JavaBean/POJO class. The class must have non-static fields. This shortcut brings the Generate hashCode() and equals() dialog as below:Select the fields to be used in hashCode() and equals() method, and then click OK. We got the following result (example):
  25. Alt + Shift + S, S: Generates toString() method. This shortcut comes in handy if we want to override toString() method that returns information of relevant fields of the class. This brings the Generate toString() dialogas below:And here’s sample of a generated toString() method:

Eclipse Java Code Formatter Xml Download

Related Eclipse Shortcut Keys Tutorials:

Other Eclipse Tutorials:

Eclipse Java Code Completion Not Working

Eclipse Java Code

Eclipse Java Code Coverage

About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.