Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

i have problem about my java code.here is my code

Java
 Scanner sc = new Scanner(System.in);
 String []s = {"A","S","D"};
 String  choice ="";
for(int i=0;i<s.length;s++)
  {
     System.out.println("Enter Your Choice:")
     sc.next();
     /* now i want to check user inserted value is only A ,D or s if other  Value it should have to show error message;i have used one but it is not working */
      if((!"A".equals(choice)) || (!"B".equals(choice)) || (!"C".equals(choice)) || (!"D".equals(choice) ))
         {
              System.out.println("not a ABCD");
              choice =sc.next();
           }



  }
Posted
Updated 2-Jul-15 23:42pm
v4

1 solution

Java
bool isASD = Arrays.asList(s).contains(answer)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900