InnovationM Interview Question

Write a program to replace string like from abc to replace ab with c and bc with a and ca with a

Interview Answer

Anonymous

Aug 20, 2019

String s="abc bcd cad"; String s1=s.replace('abc' , 'ab'); String s2=s.replace('bc' ,'a'); String s3=s.replace('ca' , 'a'); System.out.println(s1); System.out.println(s2); System.out.println(s3);