将汉字和字母转换为Unicode码

package my;
public class number {
    public static void main(String[] args) {
        String text="白日依山尽,黄河入海流";
        char[] charArray=text.toCharArray();
        StringBuilder builder = new StringBuilder();
        for (char c :charArray){
            builder.append((int)c+"");
        }
        System.out.println("【白日依山尽,黄河入海流】的Unicode是:");
        System.out.println(builder.toString());
    }
}

效果如下:

 

你可能感兴趣的:(JAVA)