Wednesday 8 June 2016

Playing with Annonymous inner class


Annonymous inner class

Thread T= new Thread()
{};
//annonumous inner class extends Thread class, in short it's  extedns parent Thread

Runnable R= new Runnable()
{
};
is it possible , yes
it's not runnable object it's an object of annonumous class which implement Runnable
else you can't crate an object of Interface

Example

public class AnnnerClass {

public static void main(String[] args) {

A a=new A()
{

public void m1()
{

System.out.println("spicy");
}
};

a.m1();

}
}


public class A {

public void m1()
{
System.out.println("swetty");
}
}
here annonymous A extends A,  and call child class object. 

4 comments:

  1. It is just what I was looking for and quite thorough as well. Thanks for posting this, http://www.proessaywriting.com/
    I saw a couple other similar posts but yours was the best so far. The ideas are strongly pointed out and clearly emphasized. 

    ReplyDelete
    Replies
    1. Thanks Loaran, I will post more contet,which gonna help to everyone

      Delete
  2. A new type of online investment that is provocative.

    Sbobet Luckily, all bets on the selected gambler are included. Make profits to bet on the full day with the selected gambler. Always give good returns. The profit is very high. Gambling and exposure to gambling to bet the top. The return of the lot. You can bet on the real chance to play it straight.

    By gambling to play as you like. Gambling is good. Gambling is a way to fill in and experience gambling in various forms. To play more easily. Ready to play realistic online gambling. Live from the real casino. How to play gambling luck to play at our website. The chance to play as you like. Gambling is good. Gambling is a complement to and exposure to various forms of betting. Get more easy gamblers. Ready to play a realistic online gambling. Live from the real casino. How to play gambling at the gambling site. IBCbet

    ReplyDelete