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

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.

主站蜘蛛池模板: 饶河县| 新兴县| 长葛市| 清丰县| 丰宁| 许昌市| 西盟| 讷河市| 沈丘县| 徐水县| 集贤县| 邵武市| 崇州市| 盐池县| 扎赉特旗| 兴业县| 东方市| 九寨沟县| 威宁| 寿宁县| 桐庐县| 霍山县| 常熟市| 新余市| 长岭县| 大宁县| 漳州市| 探索| 黔江区| 新安县| 呼和浩特市| 开封县| 樟树市| 军事| 涪陵区| 泗洪县| 山丹县| 湘潭县| 迁西县| 兴义市| 泊头市|