Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5009362

In class one can declare enum and other variable with the same name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      one can declare enum and and other variable with the same name inside the class.

      The code mentioned below complies:-

      public class Test3 {
         
         enum color {RED, BLUE, GREEN};
         int color =78;
        
         
         public void assertion1() {
            System.out.println("Not sure what the color is :"+color);
         }
         
         
         public static void main(String args[]) {
            Test3 ref = new Test3();
            ref.assertion1();
         }

      }

      In the Enum Spec it should be documented how to access the enum in such a case,
      in the first case compiler should flag a error.



        Attachments

          Activity

            People

            Assignee:
            gafter Neal Gafter
            Reporter:
            jsinghsunw Jit Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: