4 Replies - 1673 Views - Last Post: 13 July 2011 - 06:14 AM Rate Topic: -----

#1 madhuvanthiram  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 9
  • Joined: 31-May 11

Explain anonymous inner class and adapter class

Posted 13 July 2011 - 05:43 AM

hi,
can anyone explain me the wat is anonymous inner class and adapter class.. i searched through the forum but i could nt get it....
Is This A Good Question/Topic? 0
  • +

Replies To: Explain anonymous inner class and adapter class

#2 ipushmycar  Icon User is offline

  • D.I.C Regular

Reputation: 86
  • View blog
  • Posts: 390
  • Joined: 29-August 10

Re: Explain anonymous inner class and adapter class

Posted 13 July 2011 - 05:56 AM

Inner class - Just another class defined in a class or interface.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,518
  • Joined: 23-August 08

Re: Explain anonymous inner class and adapter class

Posted 13 July 2011 - 05:59 AM

I changed your title from "Question" to something that actually DESCRIBES your issue. Don't use stupid titles like "Question"...we KNOW you have a question, DUH! Use a title that describes your issue.
Was This Post Helpful? 0
  • +
  • -

#4 madhuvanthiram  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 9
  • Joined: 31-May 11

Re: Explain anonymous inner class and adapter class

Posted 13 July 2011 - 06:01 AM

ya that fine... but we use anonymous inner class within an action listener....am i right.. but i want hte exzt meanin
Was This Post Helpful? -1
  • +
  • -

#5 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10568
  • View blog
  • Posts: 39,127
  • Joined: 27-December 08

Re: Explain anonymous inner class and adapter class

Posted 13 July 2011 - 06:14 AM

Anonymous inner classes are just classes without names. Often times you see them defined with interfaces using the syntax:
new InterfaceName(){

   //override abstract methods here
}



Anonymous and named inner classes both can have other fields, other methods, etc., just like normal outer classes. You can also define an anonymous inner class when instantiating an Object from a class. As an example:
JPanel panel = new JPanel(){

     public void paint(Graphics g){
          super.paint(g);
     }
};



The only thing with anonymous inner classes is that you can't define constructors for them, as they aren't named.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1