26 code project (reverse a string) help
Can someone help me with this project? Here's the code that I have so far, but it doesn't seem to be working: import java.util.Scanner; import java.util.Arrays; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String text = scanner.nextLine(); char[] arr = text.toCharArray(); String r = reverse("hello there"); System.out.println(r); } public static String reverse(String s) { char[] letters = new char[s.length()]; int letterIndex = 0; for (int i = s.length() - 1; i >= 0; i--) { letters[letterIndex] = s.charAt(i); letterIndex++; } String reverse = ""; for (int i = 0; i < s.length(); i++) { reverse = reverse + letters[i]; } return reverse; } }