blackjack java program
how to apply for registration in the Java programming?
Package blackjack; java.util .*; import java.io. *; Public class Johndeal (Generator random = new Random (); johnTotal int, int johnRandom; InputStreamReader istream = new InputStreamReader (System.in); BUFR = new BufferedReader BufferedReader (istream); johnDeal public void () (System.out.println ( "Player one please enter your name") String = PlayerOne BufRead.readLine (); im gettin an error saying I have to take the information to launch. All I want to do is ask the user their name and then save it as a variable. But I wonder if anyone can really explain how to configure the input.
OK, the error is because bufRead.readLine () may throw exceptions. An easy way to do so would be as follows: Instead of bufRead.readLine PlayerOne = String (); Have. PlayerOne String = ""; try (bufRead.readLine PlayerOne = ()) catch (Exception e) (/ / do something with the exception. E.printStackTrace (); / / This prints the stack trace to System.out / / You may also want to tell the user something has happened. / / … / / You wish, can exit the method. return;) I hope that makes sense.