• 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

inner class doubt

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we create a standalone subclass of an inner class outside of the its outer class, if so pls explain me with code fragment
thanks
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it CAN be done, but I wouldn't do it. You can end up with all SORTS of strange behaviors.
Read this: http://www.javaranch.com/ubb/Forum34/HTML/000485.html
 
ameen ahamed
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why the following code is not compiling?
class outer
{
String name="alpha";
class inner
{
String name="beta";
class innerinner
{
String name="gamma";
public void dosomething(){
System.out.println(name);
}
};
};
};

class test
{

public static void main(String args[]){
new outer().new childinner().dosomething();
}
};
class childinner extends outer.inner
{
String name="telta";
public void dosomething(){
System.out.println("name is "+outer.this.name);
System.out.println("2ns name is "+name);
System.out.println("3 rd name is "+ super.name);
}
};

Originally posted by Cindy Glass:
Well, it CAN be done, but I wouldn't do it. You can end up with all SORTS of strange behaviors.
Read this: http://www.javaranch.com/ubb/Forum34/HTML/000485.html


 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic