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
Random number
클래스의 정의와 인스턴스 생성
Геттеры и сеттеры для класса Dog
jb11.0 threads tick tock 1.0
word Ladder
2darray
Game developer
get top k frequent elements ( Priority Queue implementation ) Language: Editor: Layout:
Prime Factors
PE #6