StringBuilder
or a plain String
as I do here (StringBuilder
will be more efficient, admittedly, but this is probably easier to understand). This is also more similar to the python code you already have.theShift
), converting back into hex, and then getting just the numeric part of the string (without the leading 0x
). So in Java, that loop goes like this. (NOTE: in Java Integer.toString(x, 16)
does not print the leading 0x
, so we don't need to chop it off).toText
method. At this point you have the string you wanted, so that method doesn't really do anything anymore.