Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
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
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
Programmer Certification (OCPJP)
Inner class
Chitra Jay
Ranch Hand
Posts: 76
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class InnerTry { public static void main(String args[]) { B.C cc = new B().new C(); } } class A { String type = "classA"; } class B extends A { String type = "classB"; class C //NonStatic inner class { String type = "classC"; C(){ System.out.println(this.type); System.out.println(B.this.type); System.out.println(((A)B.this).type);//3 } } } Now my Question is Is there any simple way of calling the class A's type variable from C() constructor other than 3?? Thanks Chitra
Barkat Mardhani
Ranch Hand
Posts: 787
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I looked up the Moughal book. I could not find any other way.
Sun LiWei
Ranch Hand
Posts: 49
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
B.super.type
Sun LiWei
Ranch Hand
Posts: 49
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class InnerTry{ public static void main(String args[]){ B.C cc = new B().new C(); } } class D { String type="class D"; void amethod() { System.out.println("D method"); } }; class A extends D{ String type = "classA"; void amethod() { System.out.println("A method"); } } class B extends A{ String type = "classB"; void amethod() { System.out.println("B method"); } class C //NonStatic inner class { String type = "classC"; C(){ System.out.println(this.type); System.out.println(B.this.type); System.out.println(B.super.type);//3 B.super.amethod(); } } }
I have another question,How can i call the amethod() in class D??? :roll:
Vin Kris
Ranch Hand
Posts: 154
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
sometimes i'd wish there was a scope resolution operator in
java
too.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Question about top-level nested class/static inner class
I Can't access superclass's method
Inner Classes
Nested Classes
Inner class and this ?
More...