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
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide
this week in the
Programmer Certification
forum!
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:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
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.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
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...