Well, it isn't a global field is an instance variable of your class.
And there is another way to access it. Just rename either the instance
variable or the local variable.

Tamas


On 11/15/06, temp temp <[EMAIL PROTECTED]> wrote:
If I donot use this.aField implies that complier will never point to  global 
field ? and only way I can access the global variable is using  this ?
  Thanks & Regards
  Miro

[EMAIL PROTECTED] wrote:  Hello temp temp,

Use this.aField inside the method.


  public class Test2 {
      private String aField = " aField ";

      public static void main(String[] args) {
          Test2 test2 = new Test2();
          test2.testField();
          System.out.println(test2.aField);
      }

      private void testField() {
          String aField = "test1";
          System.out.println(aField);
          System.out.println(this.aField);
      }
  }


Thanks and regards,
Pazhanikanthan. P (Paz)

Consultant for AXA,
Senior Software Engineer,
HCL Australia Services Pty. Ltd.
Off   : +61-3-9618-4085
Mob : +61-0411-354-838




temp temp
15/11/2006 07:13 AM
Please respond to "Struts Users Mailing List"

        To:     user@struts.apache.org
        cc:
        Subject:        Simple java question


    I declared  a private global field called aField.
      The same  variable I decalred in a method .
                      For example
  public class Test2 {
      private String aField = " aField ";

      public static void main(String[] args) {
          Test2 test2 = new Test2();
          test2.testField();
          System.out.println(test2.aField);
      }

      private void testField() {
          String aField = "test1";
          System.out.println(aField);
      }
  }
  In the  method testField if I want to access the global variable  aField
is it possible ?
          Thanks  & Regards
      Miro


---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com

*********************************************************************************
Important Note
This email (including any attachments) contains information which is
confidential and may be subject to legal privilege.  If you are not
the intended recipient you must not use, distribute or copy this
email.  If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this
email are not necessarily the views of AXA.   Thank you.
**********************************************************************************



---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to