Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static String convertTwoHexString(int num) {
        // return "0x" + Integer.toHexString(num).toUpperCase();

        String temp = Integer.toHexString(num).toUpperCase();
        switch (temp.length()) {
        case 1:
            return "0x000" + temp;
        case 2:
            return "0x00" + temp;
        case 3:
            return "0x0" + temp;
        default:
            return "0x" + temp;
        }
    }
}