How can I implement a diff
function, such as Stack Overflow\'s question revision history?
I guess the only way would be to compare each character forming the 2 strings . Something like this :
void diff(String first,String second) {
int biggest = (first.length() > second.length()) ? first.length() : second.length();
for(int i = 0;i < biggest;i++) {
//compare each char from the longest string with each char from the shorter
// do something with them if they're not equal
}
}
This is just a sketch of how I would do it . Everything depends on what you want to do with the data .