Story of [Java standard input solution]

Standard input on Java edition

The content is the Java version of Last time (Python version). As for my impression, I like Python because it is simpler. Later, I felt the gratitude for the type being decided arbitrarily. The following code omits public ... etc., so only the main part is described.

The most primitive process

The work itself of creating a variable called "input" and assigning it is done with ".nextLine ()".

//Suppose the input data is

Scanner input = new Scanner(;//Define a variable that contains the input value


String l = input.nextLine();//Get as a string


int l = input.nextInt();//Get as an integer

Since Python ends with l = input (), I get the impression that it is quite sluggish ...

When they are connected side by side (acquire one by one)

//Suppose the input data is
//5 10 15

Scanner input = new Scanner(;//Define a variable that contains the input value

String l =;//Get as a string


int l =;//Get as an integer

It's relatively easy to get just one. Rather, I feel that this is good for the one above.

When it is connected horizontally (obtained as List)

//Suppose the input data is
//5 10 15

Scanner input = new Scanner(;//Define a variable that contains the input value

List<String> l = Arrays.asList(input.nextLine().split(" "));
//Get as a string. split("")Then you can take one character at a time, so it seems to be applicable.


???//Get as an integer

Utilize a variable list. One list is a lot of work ... The integer is unverified. (Scheduled to be added) I feel like I can use List (unverified).

If it is connected vertically ⇒ Add

Extra: The most primitive processing (summarized)

//Suppose the input data is

String l = new Scanner(;

//If you want to retrieve only one data, this is all. l=It becomes 5.

If you really want to retrieve only one piece of data, you can still read it. If you repeat the same syntax, an error will occur, so it seems that it can not be used very much for skill check of paiza.


[Java 8] Until converting standard input that can be used in coding tests into a list or array

Recommended Posts

Story of [Java standard input solution]
Read standard input in Java
[Java version] The story of serialization
Story of passing Java Gold SE8
[Java] Input to stdin of Process
Acquisition of input contents using Scanner (Java)
The story of writing Java in Emacs
The story of low-level string comparison in Java
The story of making ordinary Othello in Java
Java static story
[Swift] Template for receiving standard input of Paiza
[Java] How to get and output standard input
The story of learning Java in the first programming
Java standard logger
A story packed with Java's standard input Scanner
Story of test automation using Appium [Android / java]
[Java] Overview of Java
Java initializer story
Java generic story
Ruby standard input
[] Summary of Java string input (InputStream, Reader, Scanner)
[Java] Receive standard input while performing numerical checks, etc.
paiza skill check standard input / output summary [Java edition]
Story of passing Java Silver SE8 (Oracle Certified Java Programmer, Silver SE 8)
The story of making dto, dao-like with java, sqlite
Expired collection of java
Predicted Features of Java
[Java] Significance of serialVersionUID
NIO.2 review of java
Review of java Shilber
java standard functional interface
java --Unification of comments
History of Java annotation
java (merits of polymorphism)
Lombok's Java 9+ support story
NIO review of java
[Java] Three features of Java
Summary of Java support 2018
java Scanner loop input
Story of making a task management application with swing, java
(Small story) Numerical value → simple conversion method of alphabet (Java)
20190803_Java & k8s on Azure The story of going to the festival
The story of pushing Java to Heroku using the BitBucket pipeline
[Java] I want to test standard input & standard output with JUnit
Use make to ease standard input of competition pro (AtCorder) C ++ / Java / Python sample Makefile posted