this is my first post, so apologies if I fail to follow proper formats/conventions etc. on this site. I've only been programming for a few weeks.
Anyways, I am writing a basic Java program using a boolean variable and a while loop. The code is very 'clunky' to say the least and could definitely be made much more elegant (though not with my limited skill set, so again, apologies). If the boolean variable is true, the code works as it should. However, if the variable is false, the code goes to a while loop and even if an input is put in which should make the statement true, the loop just keeps going. Any ideas what's causing this infinite loop. I'm practically certain it's something basic, but I just can't seem to figure it out. Here is the code below. Thanks!
import java.util.Scanner;
import java.util.Random;
import static java.lang.System.out;
import static java.lang.System.in;
public class MB1 {
public static void main(String args[]){
char a, b, c, d;
Scanner myScanner = new Scanner(in);
boolean secondBoolean;
out.println("Let's get started! Type in your 4-digit code:");
a = myScanner.findWithinHorizon(".", 0).charAt(0);
b = myScanner.findWithinHorizon(".", 0).charAt(0);
c = myScanner.findWithinHorizon(".", 0).charAt(0);
d = myScanner.findWithinHorizon(".", 0).charAt(0);
secondBoolean = ((a == '1'|| a == '2'|| a == '3' || a == '4' || a == '5' || a == '6' || a == '7')
&& (b == '1' || b == '2'|| b == '3' || b == '4' || b == '5' || b == '6' || b == '7')
&& (c == '1' || c == '2'|| c == '3' || c == '4' || c == '5' || c == '6' || c == '7')
&& (d == '1' || d == '2'|| d == '3' || d == '4' || d == '5' || d == '6' || d == '7'));
while (secondBoolean == false) {
out.println("The code you typed is not valid. Please type a different code:");
a = myScanner.findWithinHorizon(".", 0).charAt(0);
b = myScanner.findWithinHorizon(".", 0).charAt(0);
c = myScanner.findWithinHorizon(".", 0).charAt(0);
d = myScanner.findWithinHorizon(".", 0).charAt(0);
out.print(a);out.print(b);out.print(c);out.print(d);
}
if (secondBoolean == true){
out.println('0');
}
}
}