Java tutorial
//package com.java2s; public class Main { public static String removeCharInc(String str, String inc) { if (str == null) { return str; } char[] carr = str.toCharArray(); StringBuffer buf = new StringBuffer(); for (int idx = 0; idx < carr.length; idx++) { if (inc.indexOf(carr[idx]) != -1) { buf.append(carr[idx]); } } return buf.toString(); } }