P
P
Pavel Kononov2021-12-16 13:12:52
Java
Pavel Kononov, 2021-12-16 13:12:52

What is the mechanism for storing names in an array?

What is the technique for storing names in an array?
There is a list of 12,000 thousand names, they need to be sorted by name and transferred to a dynamic array, so that each line
of the array corresponds to one letter that the names begin with?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-12-16
@sfrtsp

Each letter corresponds to a new row in the array.

If there is a new array string for each letter, then am I correct in understanding that the names in the string should be concatenated, or should there just be a list of names for each letter?
I would use HashMap<Character, List<String>>
Put in mapu Character(your letters). And for the corresponding letter, add names to List<String>
If you need a variant with concatenation, then you can HashMap<Character, String>. Accordingly, when adding, you get a string and concatenate the new name with with the string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question