N
N
Nikita2018-03-16 23:08:29
Java
Nikita, 2018-03-16 23:08:29

Why can't the Set interface work like a List?

Why can't I get the elements of a Set without an iterator? (Well, for example, in a List, I can call the get(index) method) What is the main difference?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2018-03-16
@NeToster

Because set is a non-indexed collection. It has no first or third element. It has just a bunch of elements, the sequence of which is not important.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question