官术网_书友最值得收藏!

REPL

One change that seems to excite a lot of people isn't a language change at all. It's the addition of a REPL (Read-Eval-Print-Loop), a fancy term for a language shell. In fact, the command for this new tool is jshell. This tool allows us to type or paste in Java code and get immediate feedback. For example, if we wanted to experiment with the Streams API discussed in the preceding section, we could do something like this:

$ jshell 
|  Welcome to JShell -- Version 9-ea 
|  For an introduction type: /help intro 
 
jshell> List<String> names = Arrays.asList(new String[]{"Tom", "Bill", "Xavier", "Sarah", "Adam"}); 
names ==> [Tom, Bill, Xavier, Sarah, Adam] 
 
jshell> names.stream().sorted().forEach(System.out::println); 
Adam 
Bill 
Sarah 
Tom 
Xavier 

This is a very welcome addition that should help Java developers rapidly prototype and test their ideas.

主站蜘蛛池模板: 密云县| 六盘水市| 石楼县| 习水县| 乡城县| 德阳市| 舞阳县| 济宁市| 阳西县| 阿尔山市| 鄂托克前旗| 莱州市| 边坝县| 深圳市| 新沂市| 平凉市| 正宁县| 武宁县| 额济纳旗| 通江县| 米易县| 温州市| 特克斯县| 囊谦县| 安阳市| 忻州市| 东莞市| 德钦县| 肃宁县| 建宁县| 健康| 如皋市| 衡东县| 安化县| 澄迈县| 乌兰浩特市| 秀山| 尤溪县| 桐柏县| 柏乡县| 额尔古纳市|