Reputation: 7728
Basically, I have a situation like this :
I want to know why the auto completion feature does't show the variable lineItems
.
I am using Eclipse Kepler
on Mac OS
and pressing Control + Space
.
EDIT :
I have looked at otter similar questions, and I believe I have the preferences set up correctly.
Upvotes: 1
Views: 104
Reputation: 22972
Because non-static variables can not be referenced from static context
eclipse
is much more smarter than we think just add static
keyword to your list and it will show the suggestions.
Even if you write full name by your self still no use as it will give you error and from the configuration I think you will get suggestion for other functionalities.
Upvotes: 3
Reputation: 97
Make an instance of TreeFormatter, or make the instance variable static.
import java.util.LinkedList;
import java.util.List;
public class TreeFormatter {
List<String> lineItems = new LinkedList<String>();
static List<String> staticlineItems = new LinkedList<String>();
public static void main(String[] args) {
// make an instance of TreeFormatter
TreeFormatter tf = new TreeFormatter();
tf.lineItems.add("foo");
// or make it static
staticlineItems.add("bar");
}
}
Upvotes: 2