Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.out.println("enter numerical value");
- int option;
- option = input.nextInt();//read numerical value from input
- System.out.println("enter 1st string");
- String string1 = input.nextLine();//read 1st string (this is skipped)
- System.out.println("enter 2nd string");
- String string2 = input.nextLine();//read 2nd string (this appears right after reading numerical value)
- Enter numerical value
- 3 //this is my input
- enter 1st string //the program is supposed to stop here and wait for my input, but is skipped
- enter 2nd string //and this line is executed and waits for my input
- int option = input.nextInt();
- input.nextLine(); // Consume newline left-over
- String str1 = input.nextLine();
- int option = 0;
- try {
- option = Integer.parseInt(input.nextLine());
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
- String str1 = input.nextLine();
- System.out.print("Insert a number: ");
- int number = input.nextInt();
- input.nextLine(); // This line you have to add (It consumes the n character)
- System.out.print("Text1: ");
- String text1 = input.nextLine();
- System.out.print("Text2: ");
- String text2 = input.nextLine();
- int number = Integer.parseInt(input.nextLine());
- int num1 = sc.nextInt();
- int num2 = sc.nextInt();
- String name = sc.next();
- public static Scanner input = new Scanner(System.in);
- public static void main(String[] args)
- {
- System.out.print("Insert a number: ");
- int number = input.nextInt();
- System.out.print("Text1: ");
- String text1 = input.next();
- System.out.print("Text2: ");
- String text2 = input.next();
- }
- Scanner scanner = new Scanner(System.in);
- int option = scanner.nextInt();
- scanner.nextLine(); //clearing the buffer
- class ScanReader {
- /**
- * @author Nikunj Khokhar
- */
- private byte[] buf = new byte[4 * 1024];
- private int index;
- private BufferedInputStream in;
- private int total;
- public ScanReader(InputStream inputStream) {
- in = new BufferedInputStream(inputStream);
- }
- private int scan() throws IOException {
- if (index >= total) {
- index = 0;
- total = in.read(buf);
- if (total <= 0) return -1;
- }
- return buf[index++];
- }
- public char scanChar(){
- int c=scan();
- while (isWhiteSpace(c))c=scan();
- return (char)c;
- }
- public int scanInt() throws IOException {
- int integer = 0;
- int n = scan();
- while (isWhiteSpace(n)) n = scan();
- int neg = 1;
- if (n == '-') {
- neg = -1;
- n = scan();
- }
- while (!isWhiteSpace(n)) {
- if (n >= '0' && n <= '9') {
- integer *= 10;
- integer += n - '0';
- n = scan();
- }
- }
- return neg * integer;
- }
- public String scanString() throws IOException {
- int c = scan();
- while (isWhiteSpace(c)) c = scan();
- StringBuilder res = new StringBuilder();
- do {
- res.appendCodePoint(c);
- c = scan();
- } while (!isWhiteSpace(c));
- return res.toString();
- }
- private boolean isWhiteSpace(int n) {
- if (n == ' ' || n == 'n' || n == 'r' || n == 't' || n == -1) return true;
- else return false;
- }
- public long scanLong() throws IOException {
- long integer = 0;
- int n = scan();
- while (isWhiteSpace(n)) n = scan();
- int neg = 1;
- if (n == '-') {
- neg = -1;
- n = scan();
- }
- while (!isWhiteSpace(n)) {
- if (n >= '0' && n <= '9') {
- integer *= 10;
- integer += n - '0';
- n = scan();
- }
- }
- return neg * integer;
- }
- public void scanLong(long[] A) throws IOException {
- for (int i = 0; i < A.length; i++) A[i] = scanLong();
- }
- public void scanInt(int[] A) throws IOException {
- for (int i = 0; i < A.length; i++) A[i] = scanInt();
- }
- public double scanDouble() throws IOException {
- int c = scan();
- while (isWhiteSpace(c)) c = scan();
- int sgn = 1;
- if (c == '-') {
- sgn = -1;
- c = scan();
- }
- double res = 0;
- while (!isWhiteSpace(c) && c != '.') {
- if (c == 'e' || c == 'E') {
- return res * Math.pow(10, scanInt());
- }
- res *= 10;
- res += c - '0';
- c = scan();
- }
- if (c == '.') {
- c = scan();
- double m = 1;
- while (!isWhiteSpace(c)) {
- if (c == 'e' || c == 'E') {
- return res * Math.pow(10, scanInt());
- }
- m /= 10;
- res += (c - '0') * m;
- c = scan();
- }
- }
- return res * sgn;
- }
- }
- import java.io.BufferedInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- class Main{
- public static void main(String... as) throws IOException{
- ScanReader sc = new ScanReader(System.in);
- int a=sc.scanInt();
- System.out.println(a);
- }
- }
- class ScanReader....
- Scanner stringScanner = new Scanner(System.in);
- Scanner intScanner = new Scanner(System.in);
- intScanner.nextInt();
- String s = stringScanner.nextLine(); // unaffected by previous nextInt()
- System.out.println(s);
- intScanner.close();
- stringScanner.close();
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int i = scan.nextInt();
- scan.nextLine();
- double d = scan.nextDouble();
- scan.nextLine();
- String s = scan.nextLine();
- System.out.println("String: " + s);
- System.out.println("Double: " + d);
- System.out.println("Int: " + i);
- }
- int firstNumber = input.nextInt();
- int secondNumber = input.nextInt();
- int i = new Scanner(System.in).nextInt();
Add Comment
Please, Sign In to add comment