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
Зареєструйся Зараз
або Підпишись на майбутні тести