Nested for loops in Java

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: 6
    • Component/s: specification
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      It would be very convenient to be able to have multiple nested foreach loops into one foreach loop by adding as many ":" as required.

      JUSTIFICATION :
      It's necessary to avoid wasting code space and the code will be very much like reading a sentence.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      this would require enhancing the current foreach loop in the following manner:

      for(City city : Array<Country> countries : Array<Continent> continents : Array<planet> planets) {
          System.out.println("Here's a list of all the cities in the solar system: " + city.getName());
      }

      CUSTOMER SUBMITTED WORKAROUND :
      use multiple for each loops; for example:

      for(Planet planet : planets) {
         for(Continent continent : planet) {
            for(Country country : continent) {
              for(City city : country) {

          System.out.println("Here's a list of all the cities in the solar system: " + city.getName());

      }

            Assignee:
            Alex Buckley
            Reporter:
            Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: