Patrick Dwyer

Echo :: Java

in News, Java, Comparative Programming by patrick

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:

Compiling the example

From the command line:


Running the example

java echo Hello World