Monday, March 8, 2010

local inner class method  

0 comments

  • Sometimes we can declare a class inside a method such type of classes are called method local

inner classes

  • The main purpose of method local inner classes is to define method specific functionality

      The scope of method local inner classes is the scope of the method where it is declared.

    • This is the mostly rarely used type of inner classes.

    Example

    class Test{

    public void m1(){

    class Inner {

    public void sum(int I,int j){

    System.out.println(i+J);

    }//sum

    }//inner

    Inner i=new Inner();

    i.sum(10,20);

    //more code here

    I.sum(100,303);

    //more code here

    i.sum(102,84);

    }//m1()

    Public static void main(){

    New Test().m1();

    }

    }

    What next?

    You can also bookmark this post using your favorite bookmarking service:

    Related Posts by Categories



    0 comments: to “ local inner class method

    Extension Factory Builder