Answers for "java util scanner string input"

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
7

how to input in java

import java.util.Scanner;
...
  Scanner console = new Scanner(System.in);
  int num = console.nextInt();
  console.nextLine() // to take in the enter after the nextInt() 
  String str = console.nextLine();
Posted by: Guest on January-05-2020
0

take input from user in java using scanner

import java.util.*;  
class UserInputDemo   
{  
public static void main(String[] args)  
{  
Scanner sc= new Scanner(System.in);    //System.in is a standard input stream  
System.out.print("Enter first number- ");  
int a= sc.nextInt();  
System.out.print("Enter second number- ");  
int b= sc.nextInt();  
System.out.print("Enter third number- ");  
int c= sc.nextInt();  
int d=a+b+c;  
System.out.println("Total= " +d);  
}  
} 
Posted by: Guest on July-25-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language