Convert.java Source code

Java tutorial

Introduction

Here is the source code for Convert.java

Source

public class Convert {
    public static void main(String[] args) {
        int i = 0, num = 23658;
        char[] digits = new char[8];

        do {
            digits[i++] = Character.forDigit(num % 16, 16);
            num /= 16;
        } while (num != 0);

        for (int j = 7; j >= 0; j--)
            System.out.println(digits[j]);

        char[] hex = { 'f', '3', '6', '0' };
        num = 0;
        for (int j = 0; j < hex.length; j++) {
            num <<= 4;
            num += Character.digit(hex[j], 16);
        }
        System.out.println(num);
    }
}