[JAVA] AtCoder [Practice A] Technical memo

Introduction

Since I started * AtCoder *, I will make a note of what I do not understand I use the Kansai dialect because I have a longing for the Kansai dialect

What is the Scanner class?

Class to get standard input Used when you want to do something with the acquired input information or in an interactive program

Scanner scanner = new Scanner(System.in);
		
System.out.println("Enter something");
		
String input = scanner.nextLine();
		
System.out.println(input + "Was entered");
		
scanner.close();

When you do this ...

Enter something

Is displayed, When you enter "Good morning"

Enter something
Good morning
Good morning was entered

Is displayed

Commentary

Create an instance of Scanner class and specify System.in as an argument

You can get the input contents by using nextLine (). By the way, get the character string including spaces

Example) "Tomorrow is Arashi" ① With nextLine (), get "Tomorrow is Arashi" ② Get "Tomorrow" with next ()

AtCoder problem

Given the integers a, b, c and the string s. Display the calculation result of a + b + c and the character string s side by side.

answer

Scanner scanner = new Scanner(System.in);
		
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
String str = scanner.next();
		
System.out.println((a + b + c) + " " + str);

nextInt () receives a value of type int

Recommended Posts

AtCoder [Practice A] Technical memo
AtCoder [ABC086A] Technical memo
Create a java method [Memo] [java11]
[Technical memo] How to resolve errors
A memo that touched Spring Boot