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

how to use scanners in java

import java.util.Scanner;

Public class Scanner {
	Public static void main(String[] args) {
    	// Scanner *scanner name here* = new Scanner(System.in);
      	Scanner scan = new Scanner(System.in);
      	System.out.println("Type anything and the scanner will take that input and print it");
      	String next = scan.next();
      	System.out.println(next);
    } 
}
Posted by: Guest on August-18-2020
0

User input (scanner)

String line = scanner.nextLine();
int age = Integer.parseInt(line); // Exception-t
Posted by: Guest on April-25-2021
0

User input (scanner)

int age = scanner.nextInt();
scanner.nextLine(); //Ez fogja az ottmaradt sorvége jelet beolvasni
        
String name = scanner.nextLine();
Posted by: Guest on April-25-2021
-1

User input (scanner)

Scanner scanner = new Scanner(System.in);

System.out.println("What's your name?");
String name = scanner.nextLine();

System.out.println("What's your year of birth?");
int yearOfBirth = scanner.nextInt();
Posted by: Guest on April-25-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language