Java tutorial
//package com.java2s; public class Main { public static String replace(String string, char oldchar, char newchar) { char chars[] = string.toCharArray(); for (int w = 0; w < chars.length; w++) { if (chars[w] == oldchar) { chars[w] = newchar; break; } } return new String(chars); } }