input java
Java
import java.util.Scanner;Scanner in = new Scanner(System.in);
System.out.print("Please enter hour 1: ");
int hour1 = in.nextInt();
System.out.print("Please enter hour 2: ");
int hour2 = in.nextInt();
System.out.print("Please enter minute 1: ");
int min1 = in.nextInt();
System.out.print("Please enter minute 2: ");
int min2 = in.nextInt();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();Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = sc.nextInt();
double d = sc.nextDouble();
float f = sc.nextFloat();
// more fast way
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine(); // read line
int c = br.read(); // read single charimport java.util.Scanner; // Import the Scanner class
class MyClass {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in); // Create a Scanner object
System.out.println("Enter username");
String userName = myObj.nextLine(); // Read user input
System.out.println("Username is: " + userName); // Output user input
}
}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
Also in Java:
- Title
- string remove last character
- Category
- Java
- Title
- java switch case
- Category
- Java
- Title
- java cast duration to long
- Category
- Java
- Title
- binary string to int java
- Category
- Java
- Title
- recursion in java
- Category
- Java
- Title
- java boolean zen
- Category
- Java
- Title
- how to create a method java
- Category
- Java
- Title
- java jaxb unmarshall xml to map
- Category
- Java
- Title
- how to make a dictionary in java
- Category
- Java
- Title
- java map declaration
- Category
- Java
- Title
- same method name with different arguments
- Category
- Java
- Title
- how to replace in java
- Category
- Java
- Title
- org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder
- Category
- Java
- Title
- gson parse json
- Category
- Java
- Title
- java observable to observer stack overflow
- Category
- Java
- Title
- ceil function in java
- Category
- Java
- Title
- how to add all list elements at once in java
- Category
- Java
- Title
- java nextpermutation
- Category
- Java
- Title
- java 8 loop in map
- Category
- Java
- Title
- java manacher's algorithm
- Category
- Java
- Title
- how to add strings together
- Category
- Java
- Title
- read a file in java and store as integer array using buffered reader
- Category
- Java
- Title
- python to java converter
- Category
- Java
- Title
- java display message
- Category
- Java
- Title
- java how to initialize an array
- Category
- Java
- Title
- osmdroid offline map does not show
- Category
- Java
- Title
- abstraction in java
- Category
- Java
- Title
- run java classpath command line
- Category
- Java
- Title
- output statement java
- Category
- Java
- Title
- 2d array length in java
- Category
- Java
- Title
- java call another constructor
- Category
- Java
- Title
- add two numbers bitwise
- Category
- Java
- Title
- exponents java
- Category
- Java
- Title
- how to print a 2d array in java
- Category
- Java
- Title
- compare list from db and list from request
- Category
- Java
- Title
- java nested for loop
- Category
- Java
- Title
- how to read in a file in java
- Category
- Java
- Title
- recursive function for fibonacci series in java javascript
- Category
- Java
- Title
- java list get first element
- Category
- Java
- Title
- StringBuilder java pop back
- Category
- Java
- Title
- declare bufferedreader java
- Category
- Java
- Title
- java script to detect the crome browser
- Category
- Java
- Title
- read and write files pattern java
- Category
- Java
- Title
- how to append to an array in java
- Category
- Java
- Title
- filesaver javafx
- Category
- Java
- Title
- create java windows application
- Category
- Java
- Title
- set preference value android
- Category
- Java
- Title
- logging in java
- Category
- Java
- Title
- java get environment variables
- Category
- Java
- Title
- imagesbutton how to set background
- Category
- Java
- Title
- how to compare strings java
- Category
- Java
- Title
- read from elasticsearch in spark
- Category
- Java
- Title
- java "->"
- Category
- Java
- Title
- java mockito print called methods
- Category
- Java
- Title
- how make a final variable in java
- Category
- Java
- Title
- countdown timer with seekbar
- Category
- Java
- Title
- java constructor genertic
- Category
- Java
- Title
- java list to array
- Category
- Java
- Title
- how to open a folder in java swing project
- Category
- Java
- Title
- java map get the key from value
- Category
- Java
- Title
- random java
- Category
- Java
- Title
- java convert a string to char[]
- Category
- Java
- Title
- double round java integer
- Category
- Java
- Title
- how to change the icon of a jframe
- Category
- Java
- Title
- convert two bytes to int java
- Category
- Java
- Title
- how to skip a line in java
- Category
- Java
- Title
- java put a char array into a string
- Category
- Java
- Title
- java get location of jar file
- Category
- Java
- Title
- java read public key from keystore
- Category
- Java
- Title
- arraylist with values
- Category
- Java
- Title
- read lines of file randomly java
- Category
- Java
- Title
- iterate hashmap java
- Category
- Java
- Title
- inheritance in java
- Category
- Java
- Title
- java random boolean
- Category
- Java
- Title
- Java array hashcode
- Category
- Java
- Title
- using class in java
- Category
- Java
- Title
- java localdate subtract two dates
- Category
- Java
- Title
- how to add an object to a list of objects in java
- Category
- Java
- Title
- int to long java
- Category
- Java
- Title
- absolute value in java
- Category
- Java
- Title
- java define custom exception
- Category
- Java
- Title
- python vs java
- Category
- Java
- Title
- java calculator code
- Category
- Java
- Title
- how to add multiple filter condition in Java stream filter chain
- Category
- Java
- Title
- java hashmap size
- Category
- Java
- Title
- java run project from command line
- Category
- Java
- Title
- java 8 printstacktrace in system.out
- Category
- Java
- Title
- int4 spring jpa failling create command
- Category
- Java
- Title
- Linked List implementation
- Category
- Java
- Title
- how to print ascii value in java
- Category
- Java
- Title
- jar file not running after being compiled
- Category
- Java
- Title
- java how to call getReader twice
- Category
- Java
- Title
- java get command line input
- Category
- Java
- Title
- send variable intent
- Category
- Java
- Title
- how to check if a string contains only alphabets and space in java
- Category
- Java
- Title
- get long from date java
- Category
- Java
- Title
- java best way to concatenate strings
- Category
- Java
- Title
- ndroid.support.v4.content.FileProvider
- Category
- Java
- Title
- else statement java
- Category
- Java
- Title
- java list contains object with property
- Category
- Java