public JComplex getComplex(Complex complex) { Enumeration e = elements(); while (e.hasMoreElements()) { JComplex jcp = (JComplex) e.nextElement(); Complex cp = jcp.getComplex(); if (complex._is_equivalent(cp)) { // refer to the same object on server return jcp; } } // is better to throw an exception for this error return null; }