class obj { void afunction(Object o) { // some function that // requires an object } } // . . . obj.afunction( new { public void object_func_1(void) { // some code here } public void object_func_2(void) { // more code here } } // end of nested class );