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:[EMAIL PROTECTED]
Sent: Tuesday, November 14, 2006 3:14 PM
To: [email protected]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]