Java Magazine, Sept/Oct 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 42 java 9 CompletableFuture supplyAsync findBestPrice LDN NYC thenCombine CompletableFuture supplyAsync queryExchangeRateFor GBP this convert completeOnTimeout DEFAULT_ PRICE 1 SECONDS thenAccept amount System out println The price is amount GBP Conclusion Java 9 helps you get around some clunky patterns when you use the Optional and Completable Future data types These changes help you write more reliable code by enabling you to better model the error cases that real business applications have to deal with The Optional improvements let you use Optionals in a way that was previously difficult and the CompletableFuture class lets you implement timeouts on external operations very easily article Raoul Gabriel Urma @ raoulUK is the CEO and cofounder of Cambridge Spark a leading learning community for data scientists and developers in the UK He is also chairman and cofounder of Cambridge Coding Academy a community of young coders and students Urma is coauthor of the best selling programming book Java 8 in Action Manning Publications 2015 He holds a PhD in computer science from the University of Cambridge Richard Warburton @ richardwarburto is a software engineer teacher author and Java Champion He is the author of the best selling Java 8 Lambdas OReilly Media 2014 and helps developers learn via Iteratr Learning and at Pluralsight Warburton has delivered hundreds of talks and training courses He holds a PhD from the University of Warwick DO YOU LIKE THIS NEW SINGLE COLUMN FORMAT FOR ARTICLES LET US KNOW AT JAVAMAG_ US@ ORACLE COM
You must have JavaScript enabled to view digital editions.