im having trouble with resetting my program.
Upon typing "y", the terminal skips all the steps to the end:
- y
- Enter an email address:
- Email is not in the list Check another email? Y/N
it skips all the procedures straight to asking for another email.
import java.util.Scanner;
import java.util.Arrays;
public class emailValid {
static Scanner sc = new Scanner(System.in);
static String mail = "";
static boolean start = false;
static String[] emails = {"alex@gmail.com","bob@gmail.com"};
public static void check(String email){
boolean contains = Arrays.stream(emails).anyMatch(email::equals);
if (contains == true) {
System.out.println("Email is in the list");
} else
System.out.println("Email is not in the list");
}
public static void main(String[] args) {
do {
System.out.println("Enter an email address:");
mail = sc.nextLine();
start = false;
check(mail);
System.out.println("Check another email? Y/N");
char yes = sc.next().charAt(0);
if (yes == 'Y' || yes == 'y') {
start = true;
} else
System.out.println("goodbye");
} while (start != false);
}
}