You can try casting. In this case, it is downcasting .
InetSocketAddress isa = (InetSocketAddress) socketAddress;
, ClassCastException, , .
instanceof:
if (socketAddress instanceof InetSocketAddress) {
InetSocketAddress isa = (InetSocketAddress) socketAddress;
// invoke methods on "isa". This is now safe - no risk of exceptions
}
SocketAddress.