loops - Java program looping help! I need to restart the program via a y/n input -
okay made program need able restart program asking if user wants try again y/n? can't seem loop correctly. me! p.s sorry formatting.
import java.util.*; import java.util.scanner; class tester {... ...} system.out.println("y/n?"); string playagain = in.nextline(); if (playagain == "y") play = true; else play = false; } } }
try this:
if ("y".equalsignorecase(playagain))
don't use == compare strings. compare reference values. want equals(): compares string contents.
Comments
Post a Comment