#java9
Explore tagged Tumblr posts
Text
3 notes
·
View notes
Photo

java: RT java: The JDK 13 Train Has Left the Station DustinMarx #JDK13 #Java https://t.co/J7jxuY3ZS2 http://twitter.com/JavaTutorialaz/status/1089710458322456582
12 notes
·
View notes
Photo

learn android app development course from beginner level to expert level. #DealEndingSoon #androiddev #androidgames #android #android8 #developer #developers #appdeveloper #java #java9 #androidapps #mobiledev #mobileapps #mobileappdevelopment #education #educationfirst http://dotnetdetail.com/learn-android-app-development-course-beginner-level-expert-level/
#androiddev#mobileapps#education#android8#developers#educationfirst#androidgames#androidapps#android#mobiledev#developer#java#java9#mobileappdevelopment#appdeveloper#dealendingsoon
2 notes
·
View notes
Photo

Java 9 Concurrency- Advanced Elements ☞ http://deal.techcus.com/p/ryHaAmU5-?utm_source=3
#Javascript
9 notes
·
View notes
Text
TakeWhile & DropWhile in Java 9 Streams with Examples
One of the most significant features introduced in Java 8 was Streams API. Since then, as Streams is on demand, later releases also focuses on improving or adding the news features in the same. That's where 2 more Stream operations came into picture with the release of Java 9. Here are we going to see two more collections that have been added as part of the Java 9 release i.e DropWhile & TakeWhile.
In this tutorial, we are going to cover below topics: What is takeWhile & dropWhile operations in Streams? How to implement it with example?
1. What is takeWhile & dropWhile operations in Streams?
takeWhile takeWhile expects a predicate and returns a new stream consisting only of the elements that match the given predicate. But, it classifying among three different cases. Let's understand all of them, If the stream is Ordered: It returns a stream consisting of the longest prefix of elements taken from this stream that match the given predicate. If this stream is ordered then the longest prefix is a contiguous sequence of elements of this stream that match the given predicate. The first element of the sequence is the first element of this stream, and the element immediately following the last element of the sequence does not match the given predicate. Stream.of(1, 3, 5, 7, 9, 13, 16, 17, 19) .takeWhile(e -> e % 2 != 0) .forEach(e -> System.out.println(e)); // Output: // 1 // 3 // 5 // 7 // 9 // 13 If you notice above, 17 & 19 are also matching the predicate but because 16 is not matching, therefore, the returning stream won't consider 17 and 19 and just cut off at the failing element. If the stream is Un-Ordered: It returns a stream consisting of a subset of elements taken from this stream that match the given predicate. If this stream is unordered, and some (but not all) elements of this stream match the given predicate, then the behavior of this operation is nondeterministic; it is free to take any subset of matching elements(which includes the empty set). Set numbers = Set.of(1,3,5,2,7); numbers.stream() .takeWhile(e -> e % 2 != 0) .forEach(e -> System.out.println(e)); // Now, you can see different out all the time Or even there can be an empty set If the stream is independent of whether ordered or un0rdered (Matching all elements OR Matching none of the element): If all elements of this stream match the given predicate then this operation takes all elements means the output is same as input, or if no elements of the stream match the given predicate then no elements are taken then the output is an empty steam. Set numbers = Set.of(25, 75, 100, 125, 150); numbers.stream() .takeWhile(n -> n % 5 == 0) .forEach(e -> System.out.println(e)); // Your can always see the same result 75 125 100 150 25 as input But the order could be non deterministic Set numbers = Set.of(25, 75, 100, 125, 150); numbers.Stream .takeWhile(n -> n % 5 != 0) .forEach(e -> System.out.println(e)); // It will print out nothing
dropWhile dropWhile is the opposite of takeWhile. dropWhile drops the elements which is matching to the predicate instead of taking them as takeWhile. And, whenever it reaches to the element which does not match the predicate, it includes the remaining elements in the returned stream. Stream.of(1,3,5,7,9,13,16,17,19) .dropWhile(e -> e % 2 != 0) .forEach(e -> System.out.println(e)); // Output: // 16 // 17 // 19
2. takeWhile & dropWhile implementation example
import java.util.*; public class TakeWhile_Java9_Example { public static void main(String args) { List OrderedList = Arrays.asList(1, 3, 5, 7, 9, 13, 16, 17, 19); Set UnorderedList = Set.of(1, 3, 5, 2, 7); Set IndependentList = Set.of(25, 75, 100, 125, 150); //takeWhile //Ordered Stream Example System.out.println("takeWhile - Ordered"); OrderedList.stream() .takeWhile(e -> e % 2 != 0) .forEach(e -> System.out.println(e)); //Unordered Stream Example System.out.println("\ntakeWhile - Unordered"); UnorderedList.stream() .takeWhile(e -> e % 2 != 0) .forEach(System.out::println); //Independent Stream Example (When all elements are matching) System.out.println("\ntakeWhile - Independent (all elements matching)"); IndependentList.stream() .takeWhile(e -> e % 5 == 0) .forEach(System.out::println); //Independent Stream Example (When none of the element is matching) System.out.println("\ntakeWhile - Independent (none of the element matching)"); IndependentList.stream() .takeWhile(e -> e .forEach(System.out::println); //dropWhile //Ordered Stream Example System.out.println("\ndropWhile - Ordered"); OrderedList.stream() .dropWhile(e -> e % 2 != 0) .forEach(e -> System.out.println(e)); } } Output: takeWhile - Ordered 1 3 5 7 9 13 takeWhile - Unordered 7 5 3 takeWhile - Independent (all elements matching) 125 75 25 150 100 takeWhile - Independent (none of the element matching) dropWhile - Ordered 16 17 19 takeWhile & dropWhile are truly useful addition as part of Streams in Java 9 and can serve variety of purposes. I hope above examples could help you to get better idea on how to implement it. Do you like this Post? – then check my other helpful posts: Passing Function as a Parameter in another Method in Java 8 Collection sorting using Lambda in Java 8 Generate Prime numbers in Java 8 Other Useful References: java.util.stream by Oracle Java 8 Stream by Baeldung Read the full article
0 notes
Text
Groovy 2.5 & 3
If you have followed me for any time, you know I'm a big fan of Groovy, the super-Java-like language that runs on the JVM. You've probably heard of it, maybe you even use it, but what is less known is that it's constantly evolving and has some great new features coming soon (or already here). Inspired by some recent news, here's all about Groovy 2.5 and 3. Updates in Groovy 2.5 Groovy 2.5 added support for JDK9+, added 11 new AST transformations, and added the macro feature which makes writing AST transformations much easier. The annotations added in Groovy 2.5 include: @AutoFinal, @AutoImplement, @ImmutableBase, @ImmutableOptions, @MapConstructor, @NamedDelegate, @NamedParam, @NamedParams, @NamedVariant, @PropertyOptions, and @VisibilityOptions. - @AutoImplement: Automatically implements missing abstract methods (such as those from an Interface). You can specify an Exception to throw from those methods such as UnsupportedOperationException. It can be useful for generating test stubs or when you only need to implement a subset of inherited abstract methods. - @AutoFinal: Automatically adds final modifier to method parameters. - @MapConstructor: Adds a constructor to your class that has one Map parameter and expects field-names as keys and sets the corresponding field values. Also many annotations were improved with additional attributes. For example, @TupleConstructor now includes seven more attributes. The @Immutable annotation was updated to recognize the Date/time classes added in Java 8 are immutable, and to handle Optional. Updates in Groovy 3 Groovy 3 sports a completely rewritten parser that brings Groovy up to parity with the latest Java 11 syntax along with new Groovy-only features. It runs on JDK 8 minimum and has better support for JDK 9/10/11. The Java-like syntax now includes Java-style lambda expressions and method references, array initialization, and do/while loops, which have eluded Groovy for many years. Edit: There is hope that in the near future after working out some issues* The new parser also compiles to "indy" by default which uses Java's invokedynamic feature. This has been available for years, but was not the default before. This, along with other changes, makes Groovy code more performant. New Operators Identity: === can now be used to express identity-equal and !== and not identity-equal. Since Groovy interprets == as ".equals", it used ".is" for identity-equals in the past. The support of "===" should avoid some confusion. This is similar to JavaScript's === operator. Negative variants of operators: !instanceof and !in are now supported. This will simplify the syntax in these situations. Before you would have to type !(x instanceof Date) whereas now you can simply type x !instanceof Date. Elvis Assignment: You may be familiar with the elvis operator (?:) in Groovy. In many cases you would use this operation to provide a default when assigning a value. For example: name = name ?: 'None'. Now you can shorten this expression to have the same meaning in Groovy 3 with the following: name ?= 'None' Safe indexing: Much like the safe-reference operator, there is now a safe-indexing operator, ?. This allows you to access an index of an array (or List), but if the array is null, it will return null instead of throwing an exception. For example the following would set the value to the first value of the array, or null if the array is null: value = array?[0] Java Parity Groovy 3 support new features added from Java 8 to 11, such as lambda expressions, method references, constructor references, and even local variables (var). All flavours of lambda expressions are supported (and currently compiled to Closures): - No parameters: () -> expression - Single paramter: x -> expression - Explicit return is optional: (x, y) -> { x * y } - Types are allowed: (int x, int y) -> { return x + y } - Default values are allowed: (int x, int y = 10) -> x+y There's much more..... in fact, I'm working on updating my book, Learning Groovy, and releasing a second edition later this year, so stay tuned! Conclusion As you can see there's a ton to be excited about with Groovy 3. Groovy 3.0.0-alpha-4 is available right now so go check it out. Learn more: groovy.apache.org
0 notes
Photo
Mastering Java 9 https://www.onlineprogrammingbooks.com/mastering-java-9/
1 note
·
View note
Photo
CRUD #Java Application with Couchbase, #Java EE and WildFly https://t.co/a2wPkRvNWz #Java #JavaEE #Java9
0 notes
Photo

java: RT java: Introduction to super-resolution imaging to improve scaling JavaPDF https://t.co/ESa1R4qpBn https://t.co/omfmUmcruV http://twitter.com/JavaTutorialaz/status/1089710460008624128
10 notes
·
View notes
Photo

java: RT java: Hands-on tutorial on the basics of the #Kafka Streams API and KSQL, as well as common patterns for designing and building event-driven applications. https://t.co/nJQqQzbFA5 https://t.co/rBFTZwlOUi http://twitter.com/JavaTutorialaz/status/1089710456183242753
10 notes
·
View notes
Photo

java: How to configure a DataSource programmatically in Spring Boot. baeldung #SpringBoot https://t.co/PP3TWytcWn http://twitter.com/JavaTutorialaz/status/1089526781307179008
5 notes
·
View notes
Photo

java: Getting Started with Spring Boot https://t.co/HXQxCZXGOg https://t.co/nTgDksa4H6 http://twitter.com/JavaTutorialaz/status/1089395291642646528
5 notes
·
View notes
Photo

Get your Java dream job! Junior interview preparation ☞ https://t.co/F9s3udv75y #java Ll-H_uD7hg9u https://t.co/DXzQUvbyIB http://twitter.com/JavaTutorialaz/status/1089635262324531201
4 notes
·
View notes
Photo
@javacodegeeks : Selecting Git commits by message - Software Development Git https://t.co/frulWMBvwG
4 notes
·
View notes
Photo

java: Apache #Hadoop 3.2.0 released, get the highlights here https://t.co/DxRN97niln http://twitter.com/JavaTutorialaz/status/1089592198524481541
3 notes
·
View notes
Photo

java: How to map a bidirectional one-to-one association that shares a composite primary key in #Hibernate thjanssen123 https://t.co/Nghfiozfbq https://t.co/8FhFnDnU4j http://twitter.com/JavaTutorialaz/status/1089559479514001408
3 notes
·
View notes