Question: code in java Replace the character in the string at the n index with a '*' ifthe string is long enough to have a character

code in java

Replace the character in the string at the n index with a '*' ifthe string is long enough to have a character at the n index. Ifthe string does not have enough characters, leave the Stringas-is.


replaceCharAtIndex("A String", 0) ? "* String"
replaceCharAtIndex("*****", 3) ? "*****"
replaceCharAtIndex("A String", 1) ? "A*String"

public String replaceCharAtIndex(String s, int n) {

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!