Questions tagged as 'collection'

3
answers

Maps in Java: picking key from the value

Hello, I have a string map for string: Map<String,String> myMap = new Map<String,String>(); with a series of values myMap.put("1","valor1"); myMap.put("2","valor2"); myMap.put("3","valor3"); I would like to know what is...
asked by 31.03.2016 / 22:20
2
answers

Sort items from a Collection from a predefined value

I have a Collection of Eloquent and would like to sort it by two fields at the same time being one of them a predefined value. Ex: this Collection has several objects of type Categoria and I want to sort it so that catego...
asked by 18.07.2017 / 16:42
3
answers

Add multiple items to a list

Is there any way to add multiple Int to a list<int> at a single time? Type List<Int32> ContasNegativas = new List<Int32>(); ContasNegativas.AddRange(30301, 30302, 30303, 30304, 30305, 30306, 30341, 30342, 30...
asked by 30.11.2015 / 19:57
2
answers

Remove duplicate objects from ListMinhaClass

Galera is as follows, I have a model class with attributes that store data returned from the database. For example: public class RelacaoTransformacao { /** ID do registro no banco de dados. */ private long id; /** Indica se o teste...
asked by 30.05.2014 / 20:50
1
answer

How to use Java 8 stream in an Object list []

Imagine the following scenario: A list of Object[] . Something similar to this: List<Object[]> lista = new ArrayList<>(); Object[] dados = new Object[3]; dados[0] = 1; dados[1] = 20; dados[1] = "cristiano"...
asked by 05.09.2017 / 20:47
2
answers

Sort a list of objects by more than one attribute

How to sort a list of objects by more than one attribute? The first is the ordering of the score, then as a tiebreaker we have the number of victory and then the balance of goals. Something like this: Pontuacao pontuacao = new Pontuacao(pon...
asked by 01.12.2014 / 21:27
1
answer

How to create a pair of values within a Map in Java

Is it possible to create a Map in Java using the concept of pair that exists in C ++? I have tried using the form below, however, I can not assign values to my map. Map<String, Entry<Entry<Integer,Integer>,String>...
asked by 04.04.2015 / 21:46
1
answer

Order collection of products interleaving according to flag

I have a model called Product which has, in addition to the product data, a featured flag that says whether the products are highlighted or not. At the time of mounting the view the products should be displayed according to the fol...
asked by 25.01.2017 / 15:58
1
answer

For an unordered set of Listeners what is the best java.util.Set implementation to use?

I'm developing a Handle for a stream of data, where events will be periodically released that should be captured by a small set of Listeners from 1 to 5 listeners . This set of listeners does not need to be triggere...
asked by 11.08.2015 / 01:50
2
answers

Sort a List in java that contains null values

Good morning! In my List , when I do the sort order I would like the null values to last. I'll show you an example to get clearer: Code output (in this case the word would be the letter after the number): SEM ORDENAÇÃO: 10c 2...
asked by 24.01.2018 / 14:20