Parameters of Main, Reverse Learn programming Java

Lesson:

Functions


Exercise:

Parameters of Main, Reverse


Objetive:

Create a program named "reverse", which receives several words in the command line and displays them in reverse order, as in this example:

reverse one two three
three two one


Code:

public class Main
{
	public static void main(String[] args)
	{
		for (int i = args.length - 1; i >= 0; i--)
		{
			System.out.print(args[i]);
			System.out.print(" ");
		}
	}
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.