Questions tagged as 'java-8'

2
answers

Are there altematives for complex conditions in a lambda expression?

With lambda expressions it is possible to filter elements of a collection of objects by creating a stream of data according to the criteria passed in the expression for the filter() method, this guarantees you a way to manipulate the col...
asked by 29.02.2016 / 04:54
2
answers

Better applicability to make a functional interface

From Java 8, in order for an interface to become functional, does it need to have just one method? But we have the @FuncionalInterface annotation, which explicitly defines that this interface is functional. But what is the main difference in...
asked by 30.03.2016 / 06:42
2
answers

What is the purpose of the super command when used in the parameter declaration of a method?

In Java the command super has the function of calling the superclass constructor. However, in the declaration of method forEach() of class ArrayList it is used in a different way than usual, see the signature of the method t...
asked by 12.03.2016 / 02:45
1
answer

Stream () and parallelStreams ()

I've seen lambdas performance and streams much better than using repetition loops, so I try to use as much as possible. My question is when should I use Streams or ParallelStreams? How does this parallelism of streams occur?     
asked by 03.07.2015 / 16:49
1
answer

How to Run JavaScript on the Java 8 Nashorn Engine Programmatically

From Java 8 we have a new Engine for running JavaScript, this is Nashorn. What Java SE platform classes are involved in engine discovery and scripting? How to execute JavaScript through the Java classes themselves in this new interpreter?...
asked by 26.06.2015 / 16:16
1
answer

Sorting HashMap by value and assigning a value using java 8

I currently have the following functional scenario: A list of the Studios class with id and name: List<Studios> studios; I count repeated names in List as follows: Map<String, Integer> counts = new HashMap<...
asked by 21.09.2018 / 14:41
1
answer

Are Java 8 lambdas and streams bringing more benefits beyond conciseness?

The only benefits I realize in the lambdas and streams of Java 8 are code savings and, as the case may be, better express the author's intent. Is that all? Is there any example code that uses one of these features and is it better not onl...
asked by 23.07.2017 / 16:32
2
answers

Retrieve the first elements of an Integer list

I have a list ArrayList<Integer> list = new ArrayList<Integer>(); where I have over 40,000 records. I wonder if you have a way to get only the top 10,000. I know you have to for and move to a new list, but this requires...
asked by 16.02.2016 / 17:59
2
answers

What is the purpose of the default when used in the signature of a method?

Within the List<E> interface of Java there is the replaceAll() method whose purpose is to replace all occurrences of a specified value in a list. However, in your signature it uses the command default , this has conf...
asked by 08.03.2016 / 22:04
1
answer

What is the Java equivalent of this lambda in Ruby?

In your Inversion of Control text, Fowler uses as an example a Ruby code snippet that promotes that principle to invoke a bind method on the input field of text that passes an event name and a lambda as argument.Whenever the text input box det...
asked by 12.06.2018 / 02:52