Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:28:41+00:00 2026-06-15T07:28:41+00:00

In Eclipse, after a line like this: List list = new ArrayList(); Typing for

  • 0

In Eclipse, after a line like this:

List list = new ArrayList();

Typing “for” just beneath, and followed by “ctrl-space” (by default), will bring several options that can help completing this “for loop”:
assist

But if the variable “list” is declared far from here (e.g. as a class field) which may not be directly inferred from this context, or there are many Lists declared,then the assistance doesn’t work well:

not work
@@ split line —

enter image description here

In some cases, Eclipse can assist, but just don’t work for member variable. E.g. manually type “another” and ENTER after the “:” didn’t persuade Eclipse to guess about it….

(P.S. workable case:

Auto guessed

auto guessed

Entered wanted name, and ENTER, works great

entered wanted name, and ENTER, works great)

Does anyone have any tip to make this assistance work under such scenarios?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:28:42+00:00Added an answer on June 15, 2026 at 7:28 am

    What I usually do to solve the content assist with for loop is the following:

    • create a local variable by typing collection variable that is declared far above and a semicolon:

      list;
      
    • press Ctrl+2 L

    • Eclipse generates a new local variable declaration which looks like this:

      List list2 = list;
      
    • type my foreach and autocomplete with Ctrl+space getting the following:

      List list2 = list;
      for (Object object : list2) {
      }
      
    • place cursor on list2 in the for loop declaration and press Alt+Shift+I which stands for inline variable.

    • this results in what you want to achieve. The effort is minimal after some practicing:

      for (Object object : list) {
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Eclipse and MyEclipse create new Java files with an extra blank line after the
Eclipse 3.4[.x] - also known as Ganymede - comes with this new mechanism of
There is a mysterious error at the line ee.add(new BasicNameValuePair(uid,demo)); Eclipse says: Multiple markers
I am fairly new to eclipse as far as it regards programming. After reading
I have this line: Log.i(----------,Arrays.toString(Locale.getAvailableLocales())); This line show me a list of available languages
After installing Eclipse e4 Tools in my Eclipse 4.1.2 from update site . I
Possible Duplicate: Eclipse wont start after computer restart Lately I opened my eclipse and
After working in Eclipse for the past 3 years and memorizing all of the
After upgrading to latest Eclipse ADT 17 , whenever I start editing layout in
After coding and testing a Java application (lets say with Eclipse, but not necessarily)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.