package test; public class Rmb { private static final char[] data = {'零','壹','贰','叄','肆','伍','陆','柒','捌','玖'}; private static final char[] units = {'元','拾','佰','仟','万','拾','佰','仟','亿'}; public static String convert(int money){ StringBuffer sbf = new StringBuffer(); int uint = 0; while(money != 0){ sbf.insert(0,units[uint++]); sbf.insert(0,data[money%10]); money = money/10; } //去零 return sbf.toString().replaceAll("零[拾佰仟]","零").replaceAll("零+万","万").replaceAll("零+元","元").replaceAll("零+","零"); } public static void main(String[] args){ Rmb rmb = new Rmb(); System.out.println(rmb.convert(1011)); //输出壹仟零壹拾壹元 } }