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

Difference between Inner class and anonymous class

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am bit confused with Inner class and Anonymous class.Can you explain the differnce between the both classes with an example.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
inner classes are classes in another class. which can be declared as private.

class Outer

{
class Inner
{
}
}

if you want to create object

Outer.Inner i= new Outer().new Inner().



coming to anonymous classes there are also classes which does contain
reference variable.


say like
method like m1(new java.util.Vetor()) .
 
shankar reddy
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
inner classes are classes in another class. which can be declared as private.

class Outer

{
class Inner
{
}
}

if you want to create object

Outer.Inner i= new Outer().new Inner().



coming to anonymous classes they are also classes which does not contain
any reference variable.


say like
method like m1(new java.util.Vetor()) .
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not create multiple topics with the same question.
Continue here.
 
    Bookmark Topic Watch Topic
  • New Topic