public class abc { /**
 * @param args
 */
public static void main(String args[])
{
int three=3;
 char one='1';
 char four=(char)(three+one);
 System.out.println(+four);
 
int three1=3;
 char one1='1';
 int four1=(int)(three1+one1);
 System.out.println(four1);

} }
52
52

解决方案 »

  1.   

    想出来了 呵呵 你把  char one='1';换为char one=1;结果为4。所以道理明显了,char one='1',这个1代表字符1,而不是数字,而字符1对应的数字应该是49,所以会有那个结果!
      

  2.   

    int three=3;
     char one='1';
     char four=(char)(three+one);
     System.out.println(+four);兄弟啊,把+号去掉你再看看结果啊
      

  3.   

    还有另外一个测试,到底有什么规律啊,我晕了都。 int three=3;
     char one='1';
     char four=(char)(three+one);
     System.out.println(four);
     
    int three1=3;
     char one1='1';
     char four1=(char)(three1+one1);
     System.out.println(+four1);
      

  4.   

    我说的没有错,但是我确实没有注意+号,但是也很简单,4字符的ascii就是52,所以你去掉加号,是打印的4这个字符当然是4,但是不明白的就是为什么加一个加号就变为打印字符所对应的ascii值了,继续研究中
      

  5.   

    System.out.println(four);---打出int
    System.out.println((char)four);--打出char。char 是16位的整数。注意转换就行了。
      

  6.   

    我又测试了一下public class abc { /**
     * @param args
     */
    public static void main(String args[])
    {

     char one='a';

     System.out.println(+one);
     
    } }
    打印出97,所以很明显,就是那句话:加一个加号就变为打印字符所对应的ascii值了
      

  7.   

    懂了。+号是把字符当成数字来看。+是正数运算的意思。中间是char到int的隐式转换。
      

  8.   

    pengtao_2005(地平线) 厉害!被你抢先了,是的,就是这个意思!再次测试
    public class abc { /**
     * @param args
     */
    public static void main(String args[])
    {

     char one='a';

     System.out.println(-one);
     

    } }
    打印出-97,所以+是正数运算的意思