Monday, July 28, 2014

Convert integer to String base on various radix


package java_stringof;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class Java_StringOf {

    public static void main(String[] args) {
        int src = 0xFF;
        System.out.println("radix=2: " + Integer.toString(src, 2));
        System.out.println("radix=8: " + Integer.toString(src, 8));
        System.out.println("radix=10: " + Integer.toString(src, 10));
        System.out.println("radix=16: " + Integer.toString(src, 16));
    }
    
}

No comments:

Post a Comment