Why do i not get a value 0 when my input is 0.
import java.util.Scanner; public class Dec2Hex { public static void main(String[] args){ int dec; String hexStr = ""; int radix = 16; char[] hexChar = {'0', '1', '2', '3', '4','5','6','7','8','9', 'A', 'B', 'C', 'D', 'E', 'F'}; //Read input Scanner in = new Scanner(System.in); System.out.print("Enter an interger: "); dec = in.nextInt(); while(dec>0) { int hexDigit = dec % radix; hexStr = hexChar[hexDigit] + hexStr; dec = dec / radix; } System.out.println("The hexadecimal equivalent is: "+hexStr); } }