Question: Lab Task 0 3 a: Consider the following Java program: public class PSuffix { static void countSamePrefixSuffix ( String s , int n ) {
Lab Task a:
Consider the following Java program:
public class PSuffix
static void countSamePrefixSuffixString s int n
Stores the prefix string
String prefix ;
forint i ; i n ; i
Add the current character to the prefix string
prefix scharAti;
Store the suffix string
String suffix ssubstringn i n;
System.out.printProper prefix: prefix Proper suffix: suffix;
Check if both the strings are equal or not
if prefixequalssuffix
System.out.print prefix.length;
System.out.println;
public static void mainString args
String S "ABCAABC";
int N Slength;
countSamePrefixSuffixS N;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
