Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,165 questions

40,721 answers

573 users

How to remove duplicates from array in Java

1 Answer

0 votes
import java.util.*; 

public class MyClass {
    public static void main(String args[]) {
        Integer arr[] = {5, 2, 1, 3, 7, 1, 5, 9, 3, 3, 3};

        Set<Integer> set = new HashSet<>(Arrays.asList(arr)); 
        
        for (Integer n : set)
            System.out.printf("%d ", n);
    }
}



/*
run:

1 2 3 5 7 9 

*/

 





answered Sep 22, 2020 by avibootz

Related questions

1 answer 80 views
1 answer 68 views
1 answer 67 views
5 answers 137 views
...