String and StringBuffer should be allowed in 'foreach' construct

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 5.0
    • Component/s: core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      there is no reason that this shouldn't work:

        String text = "whatever"
         for (char c : text) { ... }


      JUSTIFICATION :
      this is exactly the reason that the 'foreach' construct was added - to simplify code where you're iterating over containers with similar values. it should be trivial to implement.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the above syntax should work.
      ACTUAL -
      you need this more complex code:

        String text = "whatever"
        for (int i = 0, len = text.length(); i < len; i++) {
          char c = text.charAt(i);
          ...
        }
      ###@###.### 2005-05-24 05:21:23 GMT

            Assignee:
            Norbert Lindenberg (Inactive)
            Reporter:
            Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: