Hello world should be the first program for the beginners In every programming language, this will be the starting point even it is very simple program. This program help you to understand how java print some message. In hackerrank this is the first step of challenges.
Task: Welcome to the world of Java! In this challenge, we practice printing to stdout.
The code stubs in your editor declare a Solution class and a main method. Complete the main method by copying the two lines of code below and pasting them inside the body of your main method.
System.out.println("Hello, World.");
System.out.println("Hello, Java.");
Input Format
There is no input for this challenge.
Output Format
You must print two lines of output:
Print Hello, World. on the first line.
Print Hello, Java. on the second line.
Sample Output
Hello, World.
Hello, Java.
Source code
public class Solution {
public static void main(String[] args) {
System.out.println("Hello, World.");
System.out.println("Hello, Java.");
}
}
System: is a final class defined in the java.lang.package
out: It is object of PrintStream type, by defualt it is public and static member field of the System class
println(): It prints any argument that passed to it ln will be print the message in the new line. If we exclude the ln from println it would not go to new line