我知道'\u000a'和'\u000d'是表示回车字符,不明白在eclipse中,char c='\u000a'为何提示字符常量无效。求解,谢谢各位!

解决方案 »

  1.   

     String s = "中国人";          
     try {
    byte[] unicodeb= s.getBytes("unicode");   
    String s_unidode = new String(unicodeb,"unicode");   
    System.out.print(s_unidode.getBytes("unicode"));
    } catch (UnsupportedEncodingException e) {     e.printStackTrace();
    }   
      
      

  2.   

    \u000a \u000d 属于单行注释,在程序里无法调用
    你可以试一下
    // \u000d hello
    compiler一样报错
    用'\n'替换就是了
      

  3.   

    char c = 0x000a;
    把html的字符和java的16进制混淆了吧。
      

  4.   

    补充一下
    你看到的char c='\u000a'
    在编译阶段实际已经被转换成char c='
    a'结果可想而知
      

  5.   

    各位,我还是没弄明白!可是,'\u000b','\u000c','\u000e','\u000f'都是合法的啊!
      

  6.   

    java中的字符是可以用Unicode编码来表示的。但是unicode中有一些比较特殊的字符,比如换行,回车等是不能用unicode代码的,在java中有其特殊的写法,如:\u000a 换行,在java中用\n来表示;\u000d 回车,在java中用\r来表示;还有\",\\等等。也就是说在用到这些字符的unicode时要用其代替.