0 votes
in JAVA by
How to find duplicate characters in a string in java?

1 Answer

0 votes
by
"public class Example {

   public static void main(String argu[]) {

      String str = ""beautiful beach"";

      char[] carray = str.toCharArray();

      System.out.println(""The string is:"" + str);

      System.out.print(""Duplicate Characters in above string are: "");

      for (int i = 0; i < str.length(); i++) {

         for (int j = i + 1; j < str.length(); j++) {

            if (carray[i] == carray[j]) {

               System.out.print(carray[j] + "" "");

               break;

            }

         }

      }

   }

}"

Related questions

0 votes
asked Oct 21, 2020 in JAVA by rahuljain1
0 votes
asked Oct 13, 2020 in JAVA by SakshiSharma
...