Convert number to Alpabet - Android java.lang

Android examples for java.lang:Integer

Description

Convert number to Alpabet

Demo Code


public class Main{

    /**/*from   w  ww . j a va 2 s  . c om*/
     * 
     * <pre>
     * StringUtil.changeAlpabet(0)  = "A"
     * StringUtil.changeAlpabet(1)  = "B"
     * StringUtil.changeAlpabet(5)  = "F"
     * StringUtil.changeAlpabet(100)= ""
     * </pre>
     * 
     * @param int
     * @return
     */
    public static String changeAlpabet(int num) {
        String[] alpabet = { "A", "B", "C", "D", "E", "F", "G", "H", "I",
                "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
                "V", "W", "X", "Y", "Z" };

        if (num > 25)
            return "";
        else
            return alpabet[num];
    }

}

Related Tutorials