Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String revers(String num) {
        num = num.toUpperCase();
        char array[] = num.toCharArray();
        for (int i = 0; i < array.length; i++) {
            if (array[i] == 'A')
                array[i] = reverseToChar(15 - 10);
            else if (array[i] == 'B')
                array[i] = reverseToChar(15 - 11);
            else if (array[i] == 'C')
                array[i] = reverseToChar(15 - 12);
            else if (array[i] == 'D')
                array[i] = reverseToChar(15 - 13);
            else if (array[i] == 'E')
                array[i] = reverseToChar(15 - 14);
            else if (array[i] == 'F')
                array[i] = reverseToChar(15 - 15);
            else
                array[i] = reverseToChar(15 - Integer.parseInt(String.valueOf(array[i])));
        }
        //
        return String.valueOf(array);
    }

    public static char reverseToChar(int num) {
        /*
         * if (num == 10) return 'A'; else if (num == 11) return 'B'; else if
         * (num == 12) return 'C'; else if (num == 13) return 'D'; else if (num
         * == 14) return 'E'; else if (num == 15) return 'F'; else return
         * String.valueOf(num).charAt(0);
         */
        return Integer.toHexString(num).charAt(0);
    }
}