java - Making a command line, if statements not working -
i want make command line, run basic commands. far, i've made people can tell program name. when don't enter name, however, treats if did. here class:
public static void main(string args[]) throws ioexception { int = 1; { system.out.print("$$: "); bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string wtt = null; // wtt = typed! wtt = br.readline(); if(wtt == null) { system.out.println("why wont tell me name!"); } else { system.out.println("thanks name, " + wtt); } } while(a == 1); }
here output
$$: well
thanks name, well
$$: hole
thanks name, hole
$$:
thanks name,
why not work?
use this
if (wtt == null || wtt.trim().length() == 0)
Comments
Post a Comment