struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paz.perias...@axa.com.au
Subject Re: Simple java question
Date Tue, 14 Nov 2006 20:29:43 GMT
Yes. You need to use the "this" qualifier to access the global variable.

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 <miroconnect@yahoo.com>
15/11/2006 07:22 AM
Please respond to "Struts Users Mailing List"
 
        To:     Struts Users Mailing List <user@struts.apache.org>
        cc: 
        Subject:        Re: Simple java question


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

paz.periasamy@axa.com.au 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.

_____________________________________________________________________ 
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.
**********************************************************************************

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message