Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Thursday

Java Program to Replace a Character from a String by index position

Java Program to Replace a Character from a String by index position

public class Sample {

public static String replaceChar(int index,String str,char replaceChar)
{
char[] charStr = str.toCharArray();
charStr[index] = replaceChar;
return String.valueOf(charStr);
}
    public static void main(String args[])
    {
   System.out.println(replaceChar(6,"malayalam",'b'));
    }
}

No comments:

Post a Comment