Created
June 18, 2017 17:48
-
-
Save thmain/9c7a5b6730e37a22ad9f38e34dffc88c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class CheckDuplicatesUsingTwoLoops { | |
public void hasDuplicates2ForLoops(int [] arrA) { | |
for (int i = 0; i < arrA.length; i++) { | |
for (int j = i+1; j < arrA.length; j++) { | |
if(arrA[i]==arrA[j]){ | |
System.out.println("Array has duplicates : " + arrA[i]); | |
} | |
} | |
} | |
} | |
public static void main(String[] args) { | |
int a [] = {1, 6, 5, 2, 3, 3, 2}; | |
new CheckDuplicatesUsingTwoLoops().hasDuplicates2ForLoops(a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public class array {
public static void main(String[] args) {
}