Java Integer to int2ABC(int index)

Here you can find the source of int2ABC(int index)

Description

int ABC

License

Open Source License

Declaration

public static String int2ABC(int index) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    final static char[] DIGITS = { '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' };

    public static String int2ABC(int index) {
        int k = index;
        int c;/*from  ww  w  .j  av  a 2 s.  co  m*/
        StringBuffer abcBuf = new StringBuffer();

        if (k == 0) {
            return "";
        }

        for (; k != 0;) {
            c = k % 26;
            if (c == 0) {
                c = 26;
            }
            abcBuf.insert(0, DIGITS[c - 1]);
            k = (k - c) / 26;
        }

        return abcBuf.toString();
    }
}

Related

  1. int2(final int x)
  2. int2(StringBuilder buf, int i)
  3. int2array(int sz, int seed)
  4. int2ba(int integer)
  5. int2BigEndianStr(int i)
  6. int2buff(int n)