Java tutorial
//package com.java2s; public class Main { public static String replaceString(String paramString, int paramInt) { char[] arrayOfChar = paramString.toCharArray(); int i = paramString.length(); for (int j = 0;; j++) { if (j >= paramInt) return String.valueOf(arrayOfChar); arrayOfChar[(-5 + (i - j))] = '*'; } } }