Java Integer Format formatINT(int n)

Here you can find the source of formatINT(int n)

Description

format INT

License

Open Source License

Declaration

public static String formatINT(int n) 

Method Source Code

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

public class Main {
    public static String formatINT(int n) {
        String s = "" + n;
        s = reverse(s);/*from  w w  w  .  j  a  va  2  s.  co  m*/
        String st = "";
        for (int i = 0; i < s.length(); i++) {
            if (i != 0 && i % 3 == 0)
                st += ",";
            st += s.charAt(i);
        }
        return reverse(st);
    }

    public static String reverse(String ss) {
        String s = "";
        for (int i = ss.length() - 1; i >= 0; i--) {
            s += ss.charAt(i);
        }
        return s;
    }
}

Related

  1. format(int spaces, String string)
  2. format(int ticks)
  3. formatInt(int i, int radix, int len)
  4. formatInt(int in, int precision)
  5. formatInt(int myint, int maxint)
  6. formatInt(int n)
  7. formatInt(int value, int length)
  8. formatInt(int value, int numDigit)
  9. formatInt(int value, int width)