Actually, there is very little in it and is probably dependent on hardware and other factors.
The setLength()
method simply alters the count and overwrites the unwanted value in the array with a zero byte.
The deleteCharAt()
performs an array copy internally, before altering the count. That sounds dramatic, but the array being copied is actually zero-length because you're removing the last character.
I would recommend going for setLength()
as it is shorter to type and I think makes it clearer what you are doing. If performance is an issue and, on measuring, you find this is the bottleneck for you, then perhaps you could consider a different algorithm that doesn't require changing the size (as per JB Nizet's answer).