Write code to Remove all the characters present in removal String from source String
//package com.book2s; public class Main { public static void main(String[] argv) { String sourceString = "book2s.com"; String removalString = "."; System.out/*from w ww . j a v a 2s. c om*/ .println(removeCharFromString(sourceString, removalString)); } /*** * Remove all the characters present in removalString from sourceString * @param sourceString * @param removalString * @return */ public static String removeCharFromString(final String sourceString, final String removalString) { final char[] removalCharArray = removalString.toCharArray(); final char[] sourceArray = sourceString.toCharArray(); final int countChar[] = new int[59]; for (char c : removalCharArray) { if (countChar[((int) c - 64)] == 0) { countChar[((int) c - 64)] = countChar[((int) c - 64)] + 1; } } for (int i = 0; i < sourceArray.length; i++) { char c = sourceArray[i]; if (countChar[((int) c - 64)] != 0) { sourceArray[i] = '\u0000'; } } return charArraytoString(sourceArray); } public static String charArraytoString(final char[] inputArray) { String finalResult = new String(); for (char c : inputArray) { if (c != '\u0000') { finalResult = finalResult + ((Character) c).toString(); } } return finalResult; } }