Command-line arguments in Java

In Java, you can receive command-line arguments through the main function. Command-line arguments are those arguments which will be passed to a program through command-line.

Program:

package com.techstackjournal;

public class Greetings {
	public static void main(String[] args) {
		System.out.println("Good Morning "+args[0]);
	}
}

Input:

java Greetings Earth

Output:

Good Morning Earth
See also  Finding Square Root of a Number in Java