pls help this replaceSubstring method occured error... public static String repl
ID: 3533331 • Letter: P
Question
pls help this replaceSubstring method occured error...
public static String replaceSubstring(String str1, String str2, String str3)
{
str1 += "";
char[] array = str1.toCharArray();
String position = new String();
String newStr = "";
StringBuilder strb = new StringBuilder(str1);
for( int i = 0; i < array.length; i++)
{
if(array[i] != ' ')
{
position += array[i];
}
else
{
if(position.equals(str2))
{
int first = i - position.length();
strb.replace(first, i, str3 );
newStr = strb.toString();
}
position = new String();
}
}
return newStr;
}
output:
Explanation / Answer
What was input?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.