Computer Science, asked by rhssrivalli, 6 months ago

Write a Java program to input a string and check whether it is a unique string or not.​

Answers

Answered by mansikundal
1

Explanation:

Create a Set like HashSet.

Get all characters of String using the chars() method.

loop over all characters and insert into Set one at a time.

If add() method return false then terminate the program because not all characters are unique.

Answered by CopyThat
1

Program: {JAVA}

import java.util.*;

public class Brainly

static void main()

{

Scanner sc=new Scanner(System.in);

int d1,d2,n,t,f=0;

System.out.println("Enter an integer:");

n=sc.nextInt();

while(n!=0)

{

d1=n%10;

t=n/10;

while(t!=0)

{

d2=t%10;

if(d1==d2)

f=1;

t=t/10;

}

n=n/10;

}

if(f==0)

System.out.println("All digits are unique");

else

System.out.println("All digits are not unique");

}

}

Similar questions