Created
February 19, 2022 16:00
-
-
Save manjaykumardp/7440fd2c4d7278fe764eebc3297a69ea to your computer and use it in GitHub Desktop.
Duplicate String in java
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
package com.manjay; | |
public class duplicate_element { | |
public static void main(String[] args) { | |
// String arr = new String[]{ } ; | |
String[] arr = new String[]{"b","a","a","a"}; | |
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].equals(arr[j])) { | |
System.out.print(arr[j] + " "); | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment