Is there a difference between explicitly putting the type into the diamond operator vs letting java figure it out?

前端 未结 4 1758
终归单人心
终归单人心 2020-12-11 18:51

Is there any difference between initialization via:

MyWrapper wrapper = new MyWrapper();

vs initialization via:

4条回答
  •  情歌与酒
    2020-12-11 19:43

    It is largely because while Java 7 is the current version, a lot of code still uses Java 6, which does not support the latter form.

    In essence, Java 7 compilers are better at infering generic types.

提交回复
热议问题