struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Asthana, Rahul" <Rahul.Asth...@CIBC.com>
Subject RE: Simple java question
Date Tue, 14 Nov 2006 20:20:18 GMT
You can do this-
      private void testField() {
          String aField = "test1";
          System.out.println(aField);
		 System.out.println("global="+this.aField);
      }
Also, name you class Struts2 instead of Test2 so that it does not feel out of place in this
List.:-)

Cheers
Rahul

-----Original Message-----
From: temp temp [mailto:miroconnect@yahoo.com]
Sent: Tuesday, November 14, 2006 3:14 PM
To: user@struts.apache.org
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.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message