1
I tried to make a program that takes a phrase and returns the phrase in reverse order. Example:
Input: "Hello, Java!";
Output: "Java! Hello,";
I tried to do it, but it’s not working.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String line1 = scanner.nextLine();
String line2 = scanner.nextLine();
String[] a = line1.split(",");
for(int i=line1.length-1; i >= 0; i--);
System.out.print(a[i] + " ");
System.out.println(line1);
System.out.println(line2);
}
}
what’s going on?
– danieltc07