I am new to Java trying to code a decimal to hexadecimal converter. The converter almost works but the numbers are flipped so I need to fix that but it wont let me due to the code having Strings. Is there anyway to fix this or an easier way that I am missing?
Thank you.
int temp, reverse;
String digits = "0123456789ABCDEF";
String hexa = " ";
while (myDecimal > 0){
int x = myDecimal % 16;
hexa = hexa + digits.charAt(x);
myDecimal = myDecimal / 16;
}
System.out.println(hexa);
temp = hexa % 10;
reverse = reverse * 10 + temp;
hexa = hexa / 10;