static public int indexOf ( String [ ] strings , String targetString ) { if ( strings == null ) return - 1 ; for ( int i = 0 ; i < strings . length ; i ++ ) { if ( strings [ i ] == null ) { if ( targetString == null ) { return i ; } } else { if ( targetString != null ) { if ( strings [ i ] . equals ( targetString ) ) { return i ; } } } } return - 1 ; }
Finds the first occurrence of the targetString in the array of strings . Returns - 1 if an occurrence wasn t found . This method will return true if a null is contained in the array and the targetString is also null .