DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 3: Understanding Janus
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • Simplify NoSQL Database Integration in Java With Eclipse JNoSQL 1.1.3

Trending

  • A Software Factory on Kubernetes: Gemini Builds, jev Decides (Genkit + senro in Go)
  • How to Format Articles for DZone
  • Decoupling a Data Pipeline From the Tables It Was Never Supposed to Depend On
  • Solving Comprehension Debt in AI-Generated Codebases

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. Java Eclipse Code Refactoring Shortcuts and Tips

Java Eclipse Code Refactoring Shortcuts and Tips

Time to get more productive when writing Java code using Eclipse!

By 
Ramesh Fadatare
·
Dec. 18, 18 · Presentation
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
50.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

This post describes some of the shortcuts and tips to refactoring a source code in Eclipse IDE with GIF images. We do refactoring most of the time when writing code. Thus, using shortcut keys or refactor menu can boost productivity.

Learn Core Java with examples in depth at  Java Tutorial | Learn Java Programming with Examples

Below are some additional Eclipse-related articles you might like:

  • How to Create a Simple Maven Project in Eclipse — In this article, we will show you how to create a simple Maven project in Eclipse IDE.
  • How to Create a Web Project Using Maven in Eclipse — In this article, we will show you how to create a web project or application using Maven in the Eclipse IDE.
  • How to Convert Java Project to Maven Project in Eclipse — In this article, we will show you how to create a Java project and convert it into the Maven project.

1. Eclipse Refactor — Extract Class

The 'Extract class...' refactoring (from Alt+Shift+T) extracts a group of fields into a separate class and replaces all occurrences to fit the new structure.

2. Eclipse Refactor — Extract Interface

Use the 'Extract interface...' refactoring technique to extract an interface out of a class (Alt-Shift-T to bring up menu).

3. Eclipse Refactor — Extract Superclass

If you want to extract part of a class into a superclass, use Alt+Shift+T to bring up the menu and select, as shown below. There are a lot of customization option available in the dialog!

4. Eclipse Refactor — Extract Method

Use this Alt + Shift + M shortcut with the Eclipse key to extract a selection to a method. This helps you move a selected block of code to a separate method with ease. For example:

5. Eclipse Refactor — Push Down

Ever wondered what 'Push down...' in the refactoring menu ( Alt+Shift+T) does? It moves methods and fields from a parent class to #all extenders. Quite handy!

6. Eclipse Refactor — Extract Local Variable

You can now declare a local variable's type as 'var' while extracting it using Alt+Shift+L (shortcut for Extract Local Variable refactoring).

7. Eclipse Refactor — Rename

Use the Alt + Shift + R shortcut to rename a variable, method, class, or even a package name. This is the most frequently used shortcut in code refactoring. Select the whole name of the class, method, or variable you want to rename and then press this shortcut:

8. Eclipse Refactor — Change Method Signature

Use the Alt + Shift + C Eclipse shortcut key to change the signature of a method. Place the cursor inside a method or select the method name, and then, press this shortcut. The Change Method Signature dialog appears. You can change various elements of method signature, such as access modifier, return type, parameters, exceptions, etc:

Happy coding!

Eclipse Java (programming language) Extract

Published at DZone with permission of Ramesh Fadatare. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 3: Understanding Janus
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • Simplify NoSQL Database Integration in Java With Eclipse JNoSQL 1.1.3

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook