java - .equals acting really funny -



java - .equals acting really funny -

(int y = 0; y < stuff.length(); y++) { string n = wordtemp[y]; string m = finish [y]; system.out.println(n + m); if (n.equals(m)); { fin = fin + 1; } } if (fin == stuff.length()) { system.out.println("completed! play 1 time again later."); return; }

this lastly part of hangman main method. have 2 arrays running. first beingness complete[], contains inputted word chopped character-by-character substring. sec array have "guessed" word array. e.g. if word fish, complete[] contain [f,i,s,h} while wordtemp contain [f,-,-,-] if guessed f.

however, when go compare elements of these 2 arrays see if user has completed challenge, jump right out of java. here's how ends going:

after taking first guess, whole thing skips out. suspect .equals isn't working, can replace it?

if (n.equals(m));

should be

if (n.equals(m))

delete semicolon.

this part of reason auto-formatting ides nice, , personally, it's, part of reason egyptian-style brackets -- if (n.equals(m)) { open bracket on same line. little things create syntax issues semicolons more obvious.

java

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -