Nick Samoylov's Blog, page 7
August 14, 2019
Java streams 11. Create from String using chars(), codePoints(), and lines()
A stream of characters (represented by integers – the code points of the characters) can be created from a string, using methods chars() or codePoints(). A stream of lines (strings) can be created from a string that includes line terminators \r or \n.
The post Java streams 11. Create from String using chars(), codePoints(), and lines() appeared first on Nick Samoylov.
August 10, 2019
Java streams 10. Create from file
A stream can be created from a file that emits either the file lines or the entries of the files tree if the file represents a directory.
The post Java streams 10. Create from file appeared first on Nick Samoylov.
July 31, 2019
Java streams 9. Create numeric stream using range()
A numeric stream can be created by methods range(startInclusive, endExclusive) and rangeClosed(startInclusive, endInclusive). The new stream emits sequential values starting with startInclusive. The difference between the methods is that rangeClosed() creates a stream that also emits endInclusive.
The post Java streams 9. Create numeric stream using range() appeared first on Nick Samoylov.
July 29, 2019
Harmful pleasure
Why unlimited indulging in savory pleasure is not good for you? If we still would like to taste something after we ate a lot already, does not it mean that the body indicates that more food is good for you?
The post Harmful pleasure appeared first on Nick Samoylov.
July 28, 2019
Laws and life
Law is the law until somebody succeeds in challenging it. But to succeed, one has to have public opinion (life) on his side.
The post Laws and life appeared first on Nick Samoylov.
July 26, 2019
What is your postal (zip) code?
People with similar interests and lifestyle live in the same neighborhood. And if you have been raised there, you adopted the same lifestyle and world view.
The post What is your postal (zip) code? appeared first on Nick Samoylov.
Java streams 8. Create using Stream.iterate()
The static Stream.iterate() method returns Stream object that emits an infinite (or finite) number of values of type T, each produced by the specified UnaryOperator applied to the previously emitted value.
The post Java streams 8. Create using Stream.iterate() appeared first on Nick Samoylov.