What's the output of the following program?
static int check(String str) {
if (str.length() <= 1)
return str.length() ;
if (str.charAt(0) == str.charAt(str.length() - 1))
{
return 1 + check(str.substring(1, str.length()
- 1));
} else {
return 0;
}
}
public static void main(String[] args) {
System.out.println(check("abba");
System.out.println(check("abeba");
System.out.println(check("abbcdebba");
}
What's the output of the following program? static int check(String str) { if (str.length() <= 1) return str.
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What's the output of the following program? static int check(String str) { if (str.length() <= 1) return str.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!