Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
// Java Coding Challenge - 09: Find out duplicate numbers using HashSet
//Title of this code //'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_45 //1, 5, 7, 54, 62, 2, 1, 54, 24, 1 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int[] numbers = {1, 5, 7, 54, 62, 2, 1, 54, 24, 1}; Set<Integer> set = new HashSet<Integer>(); for (int n : numbers) { boolean unique = set.add(n); if (!unique) //(!unique == false) System.out.println("Duplicate: " + n); } } }
run
|
edit
|
history
|
help
0
OurDate.java
names
circleapp.java
innerclss
Display Page
Print Count Strings
m-primes
linkl
Street light
PE #3