java - Scanner delimiter passed with parameter? -
I need to parse an input-line character by character, and it will be done in many ways. All around to do this, I'm using the delimiter (""). My question is is do I have to set this delimiter in every way? Or is it enough once in the beginning?
For example
zero start () {in the scanner = new scanner (System.in); In.useDelimiter (""); char first = in.next (); (In) readSecond; ...} Zero read second (in the scanner) {//in.useDelimiter (""); & Lt; - Is it necessary? Four seconds = in.next (); ...} Example Input: A5c * vd
Thanks!
You do not want to set every time, if you declare and start the scanner object in the class body There are ways that are inside. If you start the scanner in each method, then I think you have to set the delimiter in each method body.
Comments
Post a Comment