Android: Calling a function inside a function? : Is it possible to call a function from another class inside a function?

like
 

    public void function(Integer x){

         ((NextActivity)getContext()).function2(x);

     }