Pretty much all this is is that you reverse the letters of a String, like it says in the title. Good luck! (I literally just said "is" twice...) I don't know why it doesn't work. Maybe their is a problem with the test cases. Please help!
public class ReverseString {
public static String reverseString(String word) {
String reversedWord = "";
for (int i = 0; i < word.length(); i++) {
reversedWord = word.charAt(i) + reversedWord;
}
return reversedWord;
}
}
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ReverseStringTest {
@Test
public void testMonkey() {
assertEquals("yeknom", "monkey");
}
@Test
void testHome() {
assertEquals("emoh", "home");
}
@Test
void testPneumonoultramicroscopicsilicovolcanoconiosis() {
assertEquals("sisoinoconaclovociliscipocsorcimartluonomuenp", "pneumonoultramicroscopicsilicovolcanoconiosis");
}
}