• Post Reply Bookmark Topic Watch Topic
  • New Topic

Nested class  RSS feed

 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not necessarily trying to hijack this thread. I understand that both @fred rosenberger and @salvin francis said perfectly and that does make sense (for the most part). However I have a couple of followup questions:

  • As stated you cannot have nested methods, but you can have nested classes correct?
  • Inside your nested class you could have a method if you choose to right?
  • Can you only go one level deep with nested classes? Or can you go many levels deep as long as you go class.nestedClassA.nestedClassAA.nestedClassAAA.method?
  • Can you have a nested anonymous method?


  • I not there with my learning yet and I know that this is not on the OCA 808 exam, but it could be on the OCP exam or some other test.
     
    salvin francis
    Bartender
    Posts: 1664
    37
    Eclipse IDE Google Web Toolkit Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Pete Letkeman wrote:
  • As stated you cannot have nested methods, but you can have nested classes correct?
  • Correct
    Pete Letkeman wrote:
  • Inside your nested class you could have a method if you choose to right?
  • Classes contain methods so yes, this is correct too.
    Pete Letkeman wrote:
  • Can you only go one level deep with nested classes? Or can you go many levels deep as long as you go class.nestedClassA.nestedClassAA.nestedClassAAA.method?
  • I do not recall if any such limitation exists, but I would really frown to see such code It would be a maintenance nightmare.
    Pete Letkeman wrote:
  • Can you have a nested anonymous method?
  • What's an anonymous method ? If you are referring to defining methods in anonymous classes, yes that's possible.
     
    Pete Letkeman
    Ranch Foreman
    Posts: 917
    26
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Great, thanks for the info @salvin francis
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!