Java Scanner input with if else statement

前端 未结 2 1401
悲&欢浪女
悲&欢浪女 2021-01-22 10:45

Hi I\'m new to java and trying to make a Quiz to practice. I wanna make a Question where the user has to combine words from to categories to pairs. Like A1 B4 C3 D2. What I did

2条回答
  •  心在旅途
    2021-01-22 11:13

    People the fact remains that the above provided answer is confusing especially to those who are relatively new to the java community. Hence the requirement is for an easier and simpler answer. Now, Java understands Strings only by the following code :

    Scanner sc=new Scanner(System.in); String a=sc.next(); if(a.equals("xyzzy")) {System.out.println("yes");

提交回复
热议问题