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

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.

主站蜘蛛池模板: 界首市| 三原县| 昭平县| 满城县| 长泰县| 北碚区| 延长县| 苗栗市| 同德县| 寿阳县| 克东县| 丹凤县| 广南县| 桐梓县| 邓州市| 平度市| 静安区| 峨边| 西安市| 志丹县| 南靖县| 镇原县| 开阳县| 偃师市| 绥化市| 双流县| 庆元县| 翁牛特旗| 襄垣县| 久治县| 济宁市| 四会市| 定兴县| 乌兰浩特市| 石屏县| 鄂伦春自治旗| 团风县| 横山县| 湘西| 喀喇沁旗| 武清区|