The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: Finding where variable is defined and where referenced

right click on the variable/method/class/etc. and choose "Open Declaration" (shortcut key is F3).

To find usage:

right click on the variable/method/class/etc and choose "References" and then in what context you want to find it's usage (in the current project, hierarchy, or workspace, or a specific working set).

You can also do a "Java search" (click the little arrow next to the search icon and choose "Java search") to search for a variety of different fields, methods, classes, etc. in whatever context you want and even how Eclipse thinks you're using it at that time.

To enable Eclipse's JDT to determine what to do about name shadowing in various contexts (ignore, warn, or throw a compiler error):

The available items are:
Field declaration hides another field or variable (this is probably one you want to change)
Local variable declaration hides another field or variable (this is probably one you want to change)
Type parameter hides another type
Method does not override package visible method
Interface method conflicts with protected 'Object' method

Note that these settings can be changed on a project-by-project basis, too.

I tend to use shadowing in constructors and setters. Mostly it's because often times I use Eclipse's automated generate getter/setter and generate constructor using fields functionality, but also because then I can quickly identify which method argument should match up with which field in my class.