Java Magazine, March/April 2016
learn more ORACLE COM JAVAMAGAZINE MARCH APRIL 2016 67 fix this objects proceeding down the stream If counted directly wed get the desired result but as the code stands the downstream filter would fail to compile because its receiving whole Fruit objects rather than color names Option B would not compile because the return type of the behavior provided as the argument to flatMap must be a stream of some kind Its interesting to note however that if the option had been sf flatMap f Stream of f getColor then although horribly inefficient and cumbersome it would have worked correctly Option C also fails to compile and is essentially nonsense The reduce method of Stream is a terminal operation that collects all the values coming down the stream and produces a single output value The behavior argument to the reduce method performs the computations that create that single output value Clearly thats not whats needed here anyway Further the behavior argument to the single argument reduce method is a BinaryOperator and the lambda f f getColor is efectively a Function Fruit String and is therefore incompatible article Simon Roberts joined Sun Microsystems in time to teach Suns first Java classes in the UK He created the Sun Certified Java Programmer and Sun Certified Java Developer exams He wrote several Java certification guides and is currently a freelance educator who teaches at many large companies in Silicon Valley and around the world He remains involved with Oracles Java certification projects Understanding enums Oracle Java tutorial on FileReader Oracle Java tutorial on Streams and aggregate operations java proposals of interest FEATURED JDK ENHANCEMENT PROPOSAL JEP 283 and JEP 263 Migrating to GTK 3 on Linux Because this issue focuses on whats inside Java lets look at how Java renders user interface elements on Linux At the moment the Linux version of the JRE depends in part on the GIMP Toolkit GTK a portable UI library written in C However Java depends on GTK 2 a rather old version of the library JEP 283 proposes migration to GTK 3 The benefit is that GTK 3 is the development branch and GTK 2 is no longer active Another driver for this change is a problem that could potentially arise namely lack of future support for GTK 2 in Linux distros Currently most versions of Linux ship with both GTK 2 and 3 However because version 3 was launched in 2011 its not clear how long the various distros will keep bundling GTK 2 This enhancement proposal therefore explores how support for version 3 could begin to be brought into AWT Swing JavaFX and potentially SWT The JDK Enhancement Proposal JEP document is particularly interesting because it presents a good overview of how much work has to be done to make a comparatively small change to a single component on a single platform It explains the benefits and drawbacks well and it lays out various transitional paths An earlier proposal JEP 263 pointed to the benefits of GTK 3 as a library to use for better support of highresolution displays If youre interested in this topic and have expertise in the matter the Expert Committees welcome your input
You must have JavaScript enabled to view digital editions.