*bookmarks link*
You see thats the thing...Even though its simpler, I didn't fully understand the logic behind it.
Indeed, its a clever way to write the method...simple-ish on the outside but complex-ish on the inside. Thats Java for you.
I just desk checked it now as well...and it seems like its created perfectly.
If we wanted to convert 1111 ro decimal (which is 15):
There would be four loops, each with i= {0,1,2,3} and the loop terminates when its less than string length (in this case 4). I think the result = result * 2 is some sort of binary shift...not too sure, but it works lol.
Cleverly done I must say.
Bookmarks