Drop Down

Monday, February 4, 2019

Duplic_Char

package interview;

public class Duplic_Char {

public static void main(String[] args)
{
String str = "abcd defg abd ghi";
  //int cnt = 0;
  char[] inp = str.toCharArray();
  System.out.println("Duplicate Characters are:");
  for (int i = 0; i < str.length(); i++)
  {
  for (int j = i + 1; j < str.length(); j++)
  {
  if (inp[i] == inp[j])
  {
  System.out.println(inp[j]);
  //cnt++;
               break;
             }
       }
   }

}}

No comments:

Post a Comment

Java 8 Notes Pics