java - Not accepting words like whats up -
My program is trying to accept words that are things, but this is not everything, It's like hello words, hello, but there is no thing to leave something as something as someone is doing wrong. There is no mistake in my code, just trying to accept the words to get it, how do you
* to change this license header, the license properties in the project properties Select. * To change this template file, select the tool. Templates * and open the template in the editor. * / Package bot; Import java.util. *; / ** * * @ Solar Kesha * / Public Category tst {Public Fixed Zero Main (string [] Args) {scanner input = new scanner (System.in); Hashmap & lt; String, Arlist & lt; String & gt; & Gt; Map = new hashmap & lt; String, Arlist & lt; String & gt; & Gt; (); // Arrayist changes your Hashet's ArrayList & LT; String & gt; List = New Arrestist & lt; String & gt; (); ArrayList & LT; String & gt; List1 = New Arrestist & lt; String & gt; (); Random R = New Random (); List.add ("hello"); List.add ("hi"); List.add ("How are you"); List.add ("hey"); List1.add ("You Eye"); Map.put ("hi", list); Map.put ("whats up", list); Map.put ("Hello", list); Map.put ("hoe", list1); System.out.println (Enter "Hi"); String str = input.next (). ToLowerCase (). Trim (); While (map.containsKey (str)) {if (map.containsKey (str)) {ArrayList & lt; String & gt; TmpList = map.get (str); Int randomNumber = r.nextInt (tmpList.size ()); Println (tmpList.get (randomNumber)); System.out.println (Enter "Hi"); Str = input.next (). ToLowerCase (). Trim (); }}}}
You are calling, from "Next token of the next Detects and gives this scanner ".
You want to call instead, which takes the full line of input.
Comments
Post a Comment