> Mam tridu, ktera obsahuje atributy jmeno, adresa, stav, atd... tj. neco
> takovehoto:
>
> public abstract class AbstractItem {
>     protected String m_name;   = "";
>     protected long m_address  = 0;
>     protected boolean m_state = false;
>     ...
> }
>
>
> Tyto objekty mam potom v poli AbstractItem[].

/**
  * Finds item in array by given name. Returns <code>null</code> if no
such item found.
  *
  * @param array searched array.
  * @param name name of searched item.
  *
  * @return the first item from array with given name, or
<code>null</code> if no item found.
  */
public static findItemByName(final AbstractItem[] array, final String name) {
    if (array == null) {
        throw new IllegalArgumentException();
    }

    if (name == null) {
        throw new IllegalArgumentException();
    }

    for (final AbstractItem item : array) {
        if (name.equals(item.getName())) {
            return item; // todo: create defense copy if necessary
        }
    }

    return null;
}

ale na to si asi prisiel aj sam. ;-)

Odpovedet emailem