aspose file tools
The moose likes Java in General and the fly likes Inner Class instantiation through Interface Reference Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Inner Class instantiation through Interface Reference" Watch "Inner Class instantiation through Interface Reference" New topic
Author

Inner Class instantiation through Interface Reference

Jayavardhan geepi
Ranch Hand

Joined: Jul 21, 2010
Posts: 66
Hi..

I have compilation error with followinf






I need Object of NestedInB class.


I have code like this






Can someone please help?
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12928
    
    3

Your variable a is of type A (even though at runtime you're initializing it with a new B), and since class NestedInB is not in class A, this is not going to work.

You have to change a to a B:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jayavardhan geepi
Ranch Hand

Joined: Jul 21, 2010
Posts: 66
Thanks Jesper...
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Inner Class instantiation through Interface Reference
 
Similar Threads
Need Help in Implementing a Set Interface
method unavailable
interface error
instanceof
Inheritance question - Interfaces