Write code to replace All Substrings
//package com.book2s; public class Main { public static void main(String[] argv) { String orig = "book2s.com"; String origSub = "o"; String newSub = "0"; System.out.println(replaceAllSubstrings(orig, origSub, newSub)); }/*from w w w . j av a 2 s . co m*/ static public String replaceAllSubstrings(String orig, String origSub, String newSub) { return orig.replaceAll(origSub, newSub); } static public StringBuilder replaceAllSubstrings(StringBuilder orig, String origSub, String newSub) { StringBuilder result = new StringBuilder(); result.append(orig.toString().replaceAll(origSub, newSub)); return result; } }