Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
outer class from inner class
Syamsul Hussin
Ranch Hand
Posts: 59
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi, can u tell me how to access an outer class varible from an inner class if the variable names are the same. thank you
----------------------------------<br />SCJP 1.4
Jim Yingst
Wanderer
Posts: 18671
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
[OuterClassName].this.[variableName]
E.g.
class Outer { private String foo = "outer foo"; public class Inner { private String foo = "inner foo"; public void method() { System.out.println(this.foo); System.out.println(Outer.this.foo); } } public static void main(String[] args) { Outer o = new Outer(); Inner i = o.new Inner(); i.method(); } }
[ February 19, 2003: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding,
Twister
Syamsul Hussin
Ranch Hand
Posts: 59
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thanks
----------------------------------<br />SCJP 1.4
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Inner classes
Instantiate Static-Nested class
How to Contruct an Inner Class Instance
Outer Class Keyword
inner class
More...