Java-String is never read error! -
this driving me insane! here's code:
public static void main(string[] strings) { int input; string source; textio.putln("please enter shift value (between -25..-1 , 1..25)"); input=textio.getint(); while ((input < 1 || input > 25) && (input <-25 || input >-1) && (input != 999 && input !=-999)) { textio.putln(input + " not valid shift value."); textio.putln("please enter shift value (between -25..-1 , 1..25)"); input=textio.getint(); } textio.putln("please enter source text (empty line quit)"); //textio.putln(source); source = textio.getln(); textio.putln("source :" + source);?"); } }
however, telling me 'source' never read! it's not allowing me input! can see problem may be?
the compiler correct; variable source
never read. you're assigning value (source = textio.getln();
), you're never reading value out.
to so, like:
textio.putln(source);
you seem having trouble reading text console textio
class. here's more standard approach, introduced in java 5:
string source; scanner in = new scanner(system.in); source = in.nextline();
what wish variable source
? stands, you're asking user enter string, you're not doing string.
Comments
Post a Comment