Question: Please write down Junit test for the following class.. .(Java Format) import java.util.*; class Palindrome { public static boolean isPalindrome(String str) { //We call reverse
Please write down Junit test for the following class.. .(Java Format)
import java.util.*;
class Palindrome { public static boolean isPalindrome(String str) { //We call reverse method to get reverse of the str String revString = reverse(str); //Comapre reverse of str and str and return the value return str.equals(revString); }
public static String reverse(String str) { //If string is empty we simply return it if(str.isEmpty()) { return str; } else { //Otherwise we recursively append whole substring from 1 to end to first character return reverse(str.substring(1))+str.charAt(0); } } }
public class PalindromTest{
(use assert) your code here//
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
