Answers for "scanner java 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
2

how to scan a String in Java

import java.util.*;
public class ScannerExample 
{
  public static void main(String args[])
{
    Scanner in = new Scanner(System.in);
    String name = in.nextLine();
    System.out.println(name);  
}
}
Posted by: Guest on March-19-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language