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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -