What will be the following code execution result?

class HashTest {
    private static Set<String> set = new LinkedHashSet<String>();
    public static void main(String[] args) {
        set.add("one");
        set.add("two");
        set.add("three");
        set.add("two");
        for (String string : set) {
            System.out.print(string + " ");
        }
    } 
}
Explanation
LinkedHashSet remembers the order of the elements insertion. As the entities are added to the table they are linked to a bidirectional linked list.
Iterator will iterate through its values ​​in the order in which they were inserted.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты