-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay0-Hello-World
More file actions
37 lines (26 loc) · 1.22 KB
/
Copy pathDay0-Hello-World
File metadata and controls
37 lines (26 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Day 0: Hello World
Problem:
Objective
In this challenge, we review some basic concepts that will get you started with this series.
You will need to use the same (or similar) syntax to read input and write output in challenges throughout HackerRank.
Check out the Tutorial tab for learning materials and an instructional video!
Task
To complete this challenge, you must save a line of input from stdin to a variable, print Hello, World. on a single line,
and finally print the value of your variable on a second line.
You've got this!
Solution:
public class Solution {
public static void main(String[] args) {
// Create a Scanner object to read input from stdin.
Scanner scan = new Scanner(System.in);
// Read a full line of input from stdin and save it to our variable, inputString.
String inputString = scan.nextLine();
// Close the scanner object, because we've finished reading
// all of the input from stdin needed for this challenge.
scan.close();
// Print a string literal saying "Hello, World." to stdout.
System.out.println("Hello, World.");
// TODO: Write a line of code here that prints the contents of inputString to stdout.
System.out.println(inputString);
}
}