java - Outputing duplicate values in 2 arraylists -
hey guys i'm kind of @ cross roads here, have 2 different arraylists of different lengths , different values. i'm trying find common values between 2 , output output text file name "output.txt". know both of arraylist filled values other textfiles, code have right not generating empty output textfile , can't figure out why program isn't outputing duplicate values textfile "output.txt"
heres code i'm using right now:
public static void duplciates(){ //compares 2 arraylists dictionary , phonewords , adds duplicates duplicates arraylist         for(string term: dictionary){             if(phonewords.contains(term)){                 duplicates.add(term);             }         }     }  public static void openoutputfile (){         try{             writer = new filewriter("e:\\output.txt");         }         catch(exception e){             system.out.println("you have error");         }      }     public static void writearraytofile(){         for(string str: duplicates){             try {                 writer.write(str);             } catch (ioexception e) {                 e.printstacktrace();             }         }     }   if guys have ideas wrong let me know, o if have better ideas on how compare 2 arraylists duplicate values let me know!
try writer.close() after writing.
Comments
Post a Comment