java - How to use Scanner.nextLine() -
I use this code to do some input in string variable n, after typing I have said, I do not want what I typed to print the program
code:
string n = scanner NXTIN ();
I think after the scanner you type something, but I do not know what it is.
EDIT: Thanks for the reply, but I do not know how to stop the scanner here is the program ...:
My program:
< code> import java.util.Scanner; Public Segment A {Public Stable Zero Main (String AZ []) {String N; Scanner ban = new scanner (System.in); System.out.println ("First Issue:"); N = bananas.nextLine (); }}When I run the program, it appears on the screen: "First digit:", then type, say I type "apple", string n " Apple will be equal ", it's okay, what I do not like, what I do not like is that the string on the screen prints the program, I did not want to do this, what happens like this:
First issue: Apple
What do I need to print the program Class I: "Without first issue", which I wrote to show him, just keep it.
Thank you. Firstly, you have to instantiate such a scanner, such as:
Scanner Scanner = New Scanner (System.in); // If you want to read from the console
, you can get your input.
string n = scanner.nixine ();
When you do not need it, make sure you close your scanner:
scanner.close ();
Comments
Post a Comment