hi i want to take in a integer from the user and use a boolean true or false to find out if each number is unique?? i know how to take in the number and convert it to a string but having trouble setting conditional to compare each character. I thought you could compare each element of the string to the other element but am not sure how to do thisThis what i have so far I am only doing java 3 weeks .
import java.util.Scanner;
public class Numberunique
{
public static void main ( String args[] )
{
int userInput = 0;
boolean unique = false;
String myString = "";
Scanner input = new Scanner( System.in );
System.out.println (" enter your number");
userInput = input.nextInt();
myString = Integer.toString(userInput);
for ( int i = 0; i <= myString.length (); i ++)
{
if ( myString. charAt(0) == myString.charAt(1))
unique = false;
}
System.out.println( "the number entered " + unique );
}
}