- public class Test01 {
- public static void main(String[] args) throws IOException {
- System.out.println("请输入一串正整数数字");
- intToString();
- }
- public static void intToString() throws IOException {
- // 键盘录入
- BufferedReader bufr = new BufferedReader(new InputStreamReader(
- System.in));
- String num = bufr.readLine();
- String[] str = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
- StringBuilder sb = new StringBuilder();
- // 把键盘读取到的数据加到sb对象中
- sb.append(num);
- for (int i = 0; i < sb.length(); i++) {
- // sb对象内的字符串对象装换成整数对象
- int j = Integer.parseInt(sb.substring(i, i + 1));
- System.out.print(str[j]);
- }
- }
- }
复制代码 |
|