Create a program that when given a four word sentence as CMD arguments, it prints it backwards.
E.g the sentence “How are you Today”, will be printed as “Today you are How”.
Sample run 1: Sample run 2:
java lab02_task01 how are you today java lab02_task01 we are going home
Output: today you are how Output: home going are we
1
Expert's answer
2021-09-15T11:41:55-0400
public class Main {
public static void main(String[] args) {
if (args.length > 0) {
for (int i = args.length - 1; i >= 0; i--) {
System.out.print(args[i] + " ");
}
}
}
}
Comments
Leave a comment