What We Are Learn On This Post
Duplicate Array Elements Java Program
How to Find Out Duplicate Array Elements Using Java Example Program?
Check Also: This Keyword In Java
package com.hcl.tmobile.submitservicechange; public class Find_Duplicate_Element_Array { public static void main(String[] args) { String[] strArray = {"abc", "def", "mno", "xyz", "pqr", "xyz", "def"}; for (int i = 0; i < strArray.length-1; i++) { for (int j = i+1; j < strArray.length; j++) { if( (strArray[i].equals(strArray[j])) && (i != j) ) { System.out.println("Duplicate Element is : "+strArray[j]); } } } } }
Leave a Reply