Why convert to String and then back?
You can multiply the first number with a power of ten and add the second to it. That's a high magnitude quicker!
Example:
given
l1=12345678;
l2=87654321;
results in
l3=l1*100000000 + l2;
P.S: Just look at the source code of Long.toString() and you see that's a loop which divides by ten and prints the remainder into a string buffer. But you do the division only once and you don't need to allocate memory for your string object.
P.P.S:
if the length of the first number is unknown, then
you can get it with divide-and-conquer alogorithm. It's much faster than String.valueOf(i1).length() or (int)(Math.log10(i1)+1) or other ways. See
http://stackoverflow.com/questions/1...gits-in-an-int