mehul chauhan :
I need the different of characters between two words ex. (1) Sunday (2) Sundey different character i need e
ex. (1) Monday (2) Monbuy different character i need bu
Ravi :
Have tested with the input you have given, working perfectly in those cases
private static String getDifferentChar(String data, String compareWithData) {
if(data == null || compareWithData == null) return null;
int dataLength = data.length();
int compareWithDataLength = compareWithData.length();
String differentChar = "";
int pos =0;
if(pos<dataLength && compareWithDataLength >=dataLength) {
while(pos<dataLength) {
if(data.charAt(pos) != compareWithData.charAt(pos)) {
differentChar+= "" + compareWithData.charAt(pos);
}
pos++;
}
if(compareWithDataLength > dataLength) {
differentChar+= "" + compareWithData.substring(dataLength);
}
}
return differentChar;
}
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=298723&siteId=1