• 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:

static member class instance

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



The class instance creation expression new ppp.Z() creates an instance of the static nested class E.Z.

New ppp.Z();//displaying Z

I tried writing the above coding in two lines. But I ended up with error. Like this

ppp myppp=new ppp();//---------this one displaying E
ppp.Z myZ=myppp.new Z();
Ans I got the error--------qualified new of static class. What does this error mean?

Ans also Creating the instance of Z is accepting (ok Creating instance of static variable or not creating instance that will display in static context.) Creating the instance of non static enclosing class is giving error? How? I am totally confused. Please help me.
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
  • creating an instance of the inner class requires a reference to an instance of the enclosing class.
  • creating an instance of the static nested class does not require an instance of the enclosing class.

  •  
    Shiva Mohan
    Ranch Hand
    Posts: 486
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the reply wise. But I am not clear yet.


    creating an instance of the static nested class does not require an instance of the enclosing class.



    But here,what is that new ppp.Z()?I thought that �new ppp �is the instance of enclosing class?
     
    wise owen
    Ranch Hand
    Posts: 2023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
     
    Shiva Mohan
    Ranch Hand
    Posts: 486
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thankyou so much for your coding.That cleared my doubt.Thanks for the time.
     
    Ranch Hand
    Posts: 304
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Shiva,

    Your code must be like this. It ran in my end.

     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic