string comparison
As we know, equals method in string does character by character comparison. It takes 2n times to compare two equal strings of n length, as pointer will be moved for 2n times.
Can anybody tell better way to compare ? Such as n time where one pointer will be kept at the begining of the string and moving other pointer for n times .....
Please, if naybody knos then tell me...............
# 3
I would be prepared to trust that the equals method uses the best way there is. It ought to.
In a low-level language like C or assembler on a 32 or 64 bit processor, you should be able to do better than comparing just one 16 bit code point from each string at a time. Hardly in Java. However, though I don't know, you might imagine that equals() be enough of native method to be implemented in a low-level langauge and use a trick like this.