Java does not use system method to convert decimal to hexadecimal

Time:2021-4-2
Note: this code is just a conversion between integers. Public class test {public static void main (string [] args) {scanner sin = new scanner( System.in );        int index =  sin.nextInt ();        String res = "";        if (index == 0) {             System.out.println (0);        } else if (index > 0){            res = getRes(index);        } else  {            index = -index;            res = "-" + getRes(index);        }         System.out.println (res);    }    public static String getRes(int index) {        String res = "";        while (index != 0) {            int t = index % 16;            if (t >= 10) {                res = (char)(t - 10 + 'A') + res;            } else {                 res = t + res;            }            index = index / 16;        }        return res;    }}