Java tutorial
//package com.java2s; public class Main { public static String ageChangeToBinaryString(int i) { String s = Integer.toBinaryString(i); Object obj = s; if (s.length() < 7) { obj = new StringBuffer(); for (i = 0; i < 7 - s.length(); i++) { ((StringBuffer) (obj)).append("0"); } ((StringBuffer) (obj)).append(s); obj = ((StringBuffer) (obj)).toString(); } return ((String) (obj)); } }