public class DuplicateElementsInArray {
public static void main(String[] args) {
//Initialize array
int [] arr = new int [] {1, 2, 3, 4, 2, 7, 8, 8, 3};
System.out.println("Duplicate elements in given array: ");
//Searches for duplicate element
for(int i = 0; i < arr.length; i++) {
for(int j = i + 1; j < arr.length; j++) {
if(arr[i] == arr[j])
System.out.println(arr[j]);
}
}
}
}
public static void main(String[] args) {
//Initialize array
int [] arr = new int [] {1, 2, 3, 4, 2, 7, 8, 8, 3};
System.out.println("Duplicate elements in given array: ");
//Searches for duplicate element
for(int i = 0; i < arr.length; i++) {
for(int j = i + 1; j < arr.length; j++) {
if(arr[i] == arr[j])
System.out.println(arr[j]);
}
}
}
}
Java Hyd Team
public class DuplicateElementsInArray { public static void main(String[] args) { //Initialize array int [] arr = new int [] {1, 2, 3, 4, 2, 7, 8, 8, 3}; System.out.println("Duplicate elements in given array: "); β¦
public class DuplicateFinder {
public static void main(String[] args) {
int[] arr = {1,2,3,4,5,3,4,7};
for (int i = 0; i < arr.length; i++) {
int element = arr[i];
boolean found = false;
for (int j = 0; j < i; j++) {
found = (arr[i] == arr[j]) ? true : false;
if (found) {
System.out.println("Duplicate element: " + element);
break;
}
}
}
}
}
Same question using ternary operator
public static void main(String[] args) {
int[] arr = {1,2,3,4,5,3,4,7};
for (int i = 0; i < arr.length; i++) {
int element = arr[i];
boolean found = false;
for (int j = 0; j < i; j++) {
found = (arr[i] == arr[j]) ? true : false;
if (found) {
System.out.println("Duplicate element: " + element);
break;
}
}
}
}
}
Same question using ternary operator
You can join here if you want any discussion or anything you want to ask ππ
Java Hyd Team
Get ready with strings concepts , jsp.
ππ strings , inheritance concepts only they asked today ππ
Soon we are going to open our tech window you can get access to immense of opportunities with this and bunch of freelance projects also ππ
https://www.fiverr.com/amanraj645/help-you-have-a-interactive-websites-that-can-be-super-good?gig_id=298195237&utm_campaign=base_gig_create_share&utm_content=&utm_medium=shared&utm_source=get_url&utm_term=&view=gig an end to end solution for your online shopping website
Fiverr.com
Amanraj645: I will help you have a interactive websites that can be super good for $405 on fiverr.com
For only $405, Amanraj645 will help you have a interactive websites that can be super good. | My last work project was buildingOrder Management Systemat [GaragePlug]. I have previously worked forTrujet Airlines.The brain fascinates me and you had me at Computationalβ¦