Does Android Studio 3 support Java 9 for Android development? If so, what features of Java 9 are supported?

As far as I know, the IDE itself supports Java 9. This means you can write a Java 9 desktop program, or run the IDE with JDK 9. However, Android itself does not support Java 9 (yet). You can still download JDK 9, although I have seen some questions on problems related to Android Studio … Read more

Private interface methods, example use-case?

Interfaces can now have default methods. These were added so that new methods could be added to interfaces without breaking all classes that implement those changed interfaces. If two default methods needed to share code, a private interface method would allow them to do so, but without exposing that private method and all its “implementation … Read more

How should I name my Java 9 module?

For a while there were two different opinions on your question but during the development of the module system, the community settled on the reverse DNS approach. Unique Module Names – Reverse DNS Here, the assumption is that module names should be globally unique. Given that goal, the most pragmatic way to get there follows … Read more

New Keywords in Java 9

The keywords added for module declarations in Java 9 are summarized in ยง3.9 of the Java Language Specification, Java SE 9 Edition: A further ten character sequences are restricted keywords: open, module, requires, transitive, exports, opens, to, uses, provides, and with. These character sequences are tokenized as keywords solely where they appear as terminals in … Read more

Map.of() vs. Collections.emptyMap()

Yes, there are even behavioral and not just technical differences between the collections returned by the emptyXyz factory methods in the Collections class and the new of factory methods introduced in the interfaces (Map, List, Set) with JDK 9, if these are invoked with no arguments. The relevant difference is that the collections returned by … Read more

What is the point of overloaded Convenience Factory Methods for Collections in Java 9

From the JEP docs itself – Description – These will include varargs overloads, so that there is no fixed limit on the collection size. However, the collection instances so created may be tuned for smaller sizes. Special-case APIs (fixed-argument overloads) for up to ten of elements will be provided. While this introduces some clutter in … Read more

Java 9 Interface vs Class

Private interface methods in Java 9 behave exactly like other private methods: They must have a body (even in abstract classes) and can neither be called nor overridden by subclasses. As such they do not really interact with inheritance. Talking of which (and particularly multiple inheritance), there are (at least?) three kinds of it: Inheritance … Read more

How is takeWhile different from filter?

filter will remove all items from the stream that do not satisfy the condition. takeWhile will abort the stream on the first occurrence of an item which does not satisfy the condition. e.g. Stream.of(1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1) .filter(i -> i < 4 ) .forEach(System.out::print); will print 123321 but Stream.of(1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1) .takeWhile(i -> i < 4 ) .forEach(System.out::print); will print … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)