Java Stdin and Stdout I HackerRank Solution

Hello Programmers, In this post, you will know how to solve the Java Stdin and Stdout I HackerRank Solution. This problem is a part of the HackerRank Java Programming Series.

Java Stdin and Stdout I HackerRank Solution
Java Stdin and Stdout I HackerRank Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Java Stdin and Stdout I HackerRank Solution


Most HackerRank challenges require you to read input from stdin (standard input) and write output to stdout (standard output).One popular way to read input from stdin is by using the Scanner class and specifying the Input Stream as For example:

Scanner scanner = new Scanner(;
String myString =;
int myInt = scanner.nextInt();
System.out.println("myString is: " + myString);
System.out.println("myInt is: " + myInt);

The code above creates a Scanner object named Scanner and uses it to read a String and an int. It then closes the Scanner object because there is no more input to read, and prints to stdout using System.out.println(String). So, if our input is:

Hi 5

Our code will print:

myString is: Hi
myInt is: 5

Alternatively, you can use the BufferedReader Class


In this challenge, you must read 3 integers from stdin and then print them to stdout. Each integer must be printed on a new line. To make the problem a little easier, a portion of the code is provided for you in the editor below.

Input Format

There are 3 lines of input, and each line contains a single integer.

Sample Input


Sample Output


Java Stdin and Stdout I HackerRank Solutions

import java.util.*;
public class Solution
    public static void main(String[] args)
        Scanner scan = new Scanner(;
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

Disclaimer: The above Problem (Java Stdin and Stdout I) is generated by Hackerrank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: Java Stdin and Stdout II in Java HackerRank Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *