Warning: Creating default object from empty value in /home/patricknevindwyer/digilutionary.com/wp-includes/functions.php on line 292
Patrick Dwyer

Echo :: Java

in News, Java, Comparative Programming by patrick

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/patricknevindwyer/digilutionary.com/wp-includes/functions-formatting.php on line 76

This program is part of the Comparative Programming :: Echo set of examples.

This single Java class is about as bare-bones as a Java program can get. We utilize a Java 5 foreach loop to retrieve each program argument and print it back to System.out, finishing with a new line.


public class echo {

public static void main(String[] args) {

for (String arg : args) {
System.out.print(arg + " ");


Program Source: echo.java

Compiling the example

From the command line:

javac echo.java

Running the example

java echo Hello World