Java: Out with the Old, In with the New

后端 未结 30 2098
遥遥无期
遥遥无期 2020-12-22 16:11

Java is nearing version 7. It occurs to me that there must be plenty of textbooks and training manuals kicking around that teach methods based on older versions of Java, whe

30条回答
  •  清歌不尽
    2020-12-22 16:35

    A simple change in since 1.5 but makes a small difference - in the Swing API accessing the contentPane of a JFrame:

    myframe.getContentPane().add(mycomponent);
    

    becomes

    myframe.add(mycomponent);
    

    And of course the introduction of Enums has changed the way many applications that used constants in the past behave.

    String.format() has greatly improved String manipulation and the ternary if statement is quite helpful in making code easier to read.

提交回复
热议问题