java - Can you see why this if statement is not working correctly? -
when run if statement returns false , doesn't run 2 lines have there. can see in above line checked if words same , identical. there here oblivious or screwed? if matters using eclipse.
boolean wordhaselement = false; (int firstdimension = 0; firstdimension <= wordnumber-1; firstdimension++){ system.out.println("-"+ words[firstdimension][0] + "-" + linewords[linewordnumber] + "-"); if (words[firstdimension][0] == linewords[linewordnumber] ){ system.out.println("worked"); wordhaselement = true; } }
if (words[firstdimension][0] == linewords[linewordnumber] ){
should replaced with
if (words[firstdimension][0].equals(linewords[linewordnumber] ){
- == checks see if 1 object same another, aren't interested in.
equals(...)
checks if 2 strings hold same string -- same letters in same order -- , that's matters. or useequalsignorecase(...)
if case doesn't matter.
Comments
Post a Comment