Java call back function works