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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Difference between Inner class and anonymous class

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Report post to moderator
Please do not create multiple topics with the same question.
Continue here.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!