Question: I created a constructor for entering a persons' title whether its Mr Mrs Miss etc. And when the user entered something different like "mister" it will repeat and ask for the user's title again. But here's the problem, When my program ask the user for the title and when you entered first correctly it will ask the user again for the title even tho i entered the title correct. Like this 

```
Enter your title (Mr,Miss,Ms, Mrs): mr
Re enter your title (Mr, Miss, Ms, Mrs): 

```

but when you entered correctly in the second input it will go to the next question. 

here the program 

```
    public void setoptions(String title1)
{
    String title0 = "Mr";
    String title2 = "Mrs";
    String title3 = "Ms";
    String title4 = "Miss";
    String choice;

    while(!(title0.equalsIgnoreCase(title) || title2.equalsIgnoreCase(title) || title3.equalsIgnoreCase(title)
            || title4.equalsIgnoreCase(title)))
     {
         System.out.println("Re enter your title (Mr, Miss, Ms, Mrs): ");
         choice=keyboard.nextLine();
         title = choice;
     }
   title = title1;

}

```

thank you :)

Answer: 
Your problem is that `title0.equalsIgnoreCase(title)` etc. should actually be `title0.equalsIgnoreCase(title1)`. In your case I assume `title` is null at first but when asking for the input you assign it the input value hence it works the second time.

Besides that you might improve your code by using a set:

```
Set<String> possibleTitles = new HashSet<>();
possibleTitles.add("mr");
possibleTitles.add("mrs");
...

//since the set internally uses equals() we need to store the elements
//and do the lookups in a common case (elements are put in lower case here,
//so we do the lookup in the same case)
if( !possibleTitles.contains( title.toLowerCase() ) {
  //ask for input, note that this should not be inside the setter
}

```
The best in my sense is to use an `Enum` and a `utility` method to make it clearer.

```
enum Titles {
    MR, MRS, MS, MISS;

    public static List<String> listValues (){
        return Stream.of(Titles.values())
                     .map(String::valueOf)
                     .collect(Collectors.toList());
    }
}

```

And your method

```
public void setTitle(String title){
    while (!Titles.listValues().contains(title.toUpperCase())) {
        System.out.println("Re enter your title (Mr, Miss, Ms, Mrs): ");
        title = keyboard.nextLine();
    }
}

```