Saturday , 20 July 2019
Home » ISC Important Programs » Java Program to check for Unique Number

Java Program to check for Unique Number


Write a Program in Java to input a number and check whether it is a Unique Number or not.

Note: A Unique number is a positive integer (without leading zeros) with no duplicate digits. For example 7, 135, 214 are all unique numbers whereas 33, 3121, 300 are not.


* The class UniqueNumber inputs a number and checks whether it is a Unique Number or not
* @author :
* @Program Type : BlueJ Program – Java

class UniqueNumber
public static void main(String args[])throws IOException
BufferedReader br=new BufferedReader(new InputStreamReader(;
System.out.print(“Enter any number : “);
int n=Integer.parseInt(br.readLine());

String s=Integer.toString(n); //converting the number into String form
int l=s.length();
int flag=0;

/* loop for checking whether there are repeated digits */
for(int i=0;i


Enter any number : 3121
**** The Number is Not a Unique Number ****
Enter any number : 5243
**** The Number is a Unique Number ****

Check Also

[Question 2] ISC 2017 Computer Practical Paper Solved – Quiz Result

Solution of Program 2 of ISC 2017 Computer Science Paper 2 (Practical) Exam. Java program to input the answers of each participant row-wise and calculate their marks


  1. nice program thanks !!!…

  2. Thank you! Very simple and easy to follow!

  3. can we convert integer into string and use string concepts in the program…?


Leave a Reply

Your email address will not be published. Required fields are marked *