class="java" name="code"> package cn.javass.hello.servletimpl.vo; import java.util.Arrays; public class NumRmb { public static void main(String[] args) { NumRmb nr = new NumRmb(); System.out.println(Arrays.toString(nr.divide(2367.123))); System.out.println(nr.toHanStr("3423")); } private String[] hanArr = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; private String[] unitArr = { "拾", "佰", "仟" }; private String[] divide(double num) { long zheng = (long) num; long xiao = Math.round((num - zheng) * 100); return new String[] { zheng + "", String.valueOf(xiao) }; } private String toHanStr(String numStr) { String result = ""; int numLen = numStr.length(); for (int i = 0; i < numLen; i++) { int num = numStr.charAt(i) - 48; //char型数字减去48就等于int数字 if (i != numLen - 1 && num != 0) { result += hanArr[num] + unitArr[numLen - 2 - i]; } else { result += hanArr[num]; } } return result; } }