java - What is my error in using a String in the case method -


i trying use scanner hold astring variable "how", , if "how" = yes execute. 'yes' case , if 'no' execute 'no' case inside else statement first question

package test; import java.util.scanner;  public class try {     public static void main(string[] args) {         system.out.println("hello world");         scanner input = new scanner(system.in);         system.out.println("do wanna make android apps");         system.out.println("yes or no ?");         string copy=input.nextline();         system.out.println(copy);          if(copy.equals("yes")) {             system.out.println("you should continue java");         } else {             system.out.println("do wanna make iso apps");             system.out.println("yes or no");             string how = null;             switch(how.tolowercase()){                 case "yes" :                     system.out.println("test worked");                     break;                 case "no":                     system.out.println("test worked 2");                     break;             }         }     } } 

 string how = null;  switch(how.tolowercase()) //here trying convert null value  

the above statement trying convert null value lowercase.

assign value

string how = input.nextline(); 

hope solves issue..


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -