A
A
Adrenal1ne12017-03-15 17:26:27
Java
Adrenal1ne1, 2017-03-15 17:26:27

How to make a selection from a sheet?

Good afternoon!
I get a table of this type from the database
Firm Goods
---------------------
Firm1 printer
Firm1 fax
Firm1 telephone
Firm2 potatoes
Firm3 vacuum cleaner
Firm3 notepad
How to write the processing of this sheet so that get the output in the console like:
Firm1 - printer, fax, phone
Firm2 - potatoes
Firm3 - vacuum cleaner, notepad
I can only iterate through the iterator and compare everything with everything. Put the first name of the company into a temporary variable. We compare the elements of the sheet with this variable by the name of the company, if the names of the companies match, then prints the product in a line. Delete a line from a sheet. Etc.
Maybe there are some other optimal solutions? And then if the table has 1,000,000 rows, then the speed will be depressing.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-03-15
@Adrenal1ne1

map = list. stream().collect(groupingBy(Db::getForm)) ;
If 8 already.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question