Answers for "scanner next string"

84

java scanner

import java.util.Scanner;

// import scanner 

Scanner myScanner = new Scanner(System.in); // Make scanner obj

String inputString = myScanner.nextLine(); // Take whole line

boolean inputBoolean = myScanner.nextBoolean(); //Boolean input

long inputLong = myScanner.nextLong(); //Interger,long ... input
Posted by: Guest on November-26-2019
0

java scanner next()

String s = "Hello World! 3 + 3.0 = 6 ";

      // create a new scanner with the specified String Object
      Scanner scanner = new Scanner(s);

      // find the next token and print it
      System.out.println("" + scanner.next()); // "Hello"

      // find the next token and print it
      System.out.println("" + scanner.next()); // "World!"

      // close the scanner
      scanner.close();
Posted by: Guest on March-05-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language