public void addToList(List<String> paths,String s){
  for (  String path : paths) {
    if (path.equals(s)) {
      return;
    }
  }
  paths.add(s);
}

public void addToList ( List < String > paths , String s ) { for ( String path : paths ) { if ( path . equals ( s ) ) { return ; } } paths . add ( s ) ; }
adds to the list only if the string s has not alreay been added
