I want to write the method listCopies() that returns in an ArrayList all copies of a written work in a given language(eg : english); if no language is given (empty string), all copies of the library will be returned (in all languages) . This is the code i have developed but it doesnt work cause in the main(String[] args) {...} it calls 2 times this method , one with the argument passed and in the second without an argument :
public ArrayList<Exemplary> listCopies(String l){
ArrayList <Exemplary> tmp = new ArrayList<Exemplary>();
for( int i = 0 ; i < copies.size(); i++){
if(copies.get(i).getWrittenWork().getLanguage().equals(language)){
tmp.add(Ex);
}
}
return (tmp);}
I want to rewrite this code in a way that with or without argument (String lang) > it returns the array tmp .
String langpassed to the method, but referenced anlanguagein the code of the method.if(language.equals(""))put a check in this way.