Java Short addition questions

后端 未结 2 1101
广开言路
广开言路 2021-01-11 13:04

This may have already been answered in another post, but I just am not getting why something won\'t compile in my test Java app (1.7.0_01).

This compiles:

         


        
2条回答
  •  余生分开走
    2021-01-11 13:52

    Here is a good example:

    public class Example {
        public static void main(String[] args) {
            Short a = (short) 17;
            a = (short) (a + a);
        }
    }
    

提交回复
热议问题