JAVA如何随机生成一个汉字

package com.test;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Random;

/** 
 * @author QiaoJiafei 
 * @version 创建时间:2015年12月21日 下午2:53:44 
 * 类说明 
 */
public class TestSiSheWuRu {
    public static void main(String args[]) {

        TestSiSheWuRu t = new TestSiSheWuRu();
        System.out.println(t.getRandomHan());
    }
    Random ran = new Random();
    private final static int DATA = 0x9fa5 - 0x4e00 + 1;
      
    public char getRandomHan() {
        return (char)(0x4e00 + ran.nextInt(DATA)); 
    }

}

 

posted on 2015-12-21 18:13  乔叶叶  阅读(1111)  评论(0编辑  收藏  举报

导航