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

methods and fields are confused

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.0
    • 0.9
    • tools
    • 1.0alpha3
    • sparc
    • solaris_2.4
    • Not verified


      The following code produces an error. It should be legal to declare
      a method and a variable with the same name.

      class test {
          int foo;

          void foo() {
          }

          void bar(test t) {
      t.foo = 1;
      t.foo();
          }
      }

      test.java:9: Attempt to reference method foo in class test as an instance variable.
              t.foo = 1;
               ^
      1 error

            ahoffsunw Arthur Hoff (Inactive)
            ahoffsunw Arthur Hoff (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: