-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumcheck.java
More file actions
26 lines (25 loc) · 762 Bytes
/
Copy pathnumcheck.java
File metadata and controls
26 lines (25 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
public class numcheck{
public static boolean check(int arr[],int n){
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
if(arr[i]==arr[j]){
return true;
}
}
}
return false;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the length of array u want:");
int n=sc.nextInt();
int arr[]=new int[n];
for (int i = 0; i < n; i++) {
arr[i]=sc.nextInt();
}
boolean result=check(arr, n);
System.out.println("There is repetition of elements in the array:"+result);
sc.close();
}
}