It sounds like you are after something like this:
public static void test(MyInterface obj){ if(obj instanceof A) { A tmp = (A)obj; } else if(obj instanceof B) { B tmp = (B)obj; } else { //handle error condition } } But please note this is very bad form and indicates something has gone seriously wrong in your design. If you don't have control of the interface then, as suggested by marcj, adding a second interface might be the way to go. Note you havecan do this whilst preserving binary compatibility.