java - Despite a condition for no equality the string is being added to the ArrayList -


i splitting direclist 2 sublists firstdirec , secondtdirec when speciefic string new direction found.

then filtering particular strings out of lists not adding them new arraylists timelistfirst , timelistsecond. works fine firstdirec, , elements not being added timelistfirst, facing problem secondtdirec list @ postion:

if (!(mergeline.equals(otherdirection)) 

since here @ position mergeline equal to"ravensbusch" , otherdirection. despite fact string being added timelistsecond. can explain me mistake?

mergeline value:

enter image description here

otherdirection value:

enter image description here

        (string keyline : direclist) {             if (keyline.startswith("new direction")) {                 int index = direclist.indexof(keyline);                 // direcarray.remove(index);                 list<string> firstdirec = direclist.sublist(0, index);                 list<string> secondtdirec = direclist.sublist(index,                         direclist.size() - 1); // part wih new                                                 // direction.                  arraylist<string> timelistfirst = new arraylist<string>();                 (string mergeline : firstdirec) {                     if (!(mergeline.equals(direction))                             && !(mergeline.equals(route))                             && !(mergeline.equals(day))) {                         timelistfirst.add(mergeline);                      }                 }                  arraylist<string> timelistsecond = new arraylist<string>();                 (string mergeline : secondtdirec) {                     if (!(mergeline.equals(otherdirection))                             && !(mergeline.equals(route))                             && !(mergeline.equals(day))                             && !(mergeline.equals("new direction"))) {                         timelistsecond.add(mergeline);                      }                 } 

it looks otherdirection's value has space @ end of it, therefore not equal , since there's ! in there, entire expression true.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -