New to the site and plan to use it a lot since I am in school for computer science. Im trying to do an error check in java on making sure a hex is enter however im being told that the string input isnt intialized.
Scanner keyboard = new Scanner(System.in);
String input;
Pattern legalInput = Pattern.compile("a-fA-F0-9");
Matcher match = legalInput.matcher(input);
boolean answer = match.find();
int counterA = 0;
while (counterA < 1) {
System.out.print("Please enter a hex number:");
input = keyboard.nextLine();
int counter = 0;
while (counter < 1) {
if (answer == true )
counter++;
else System.out.println("Error");
} counterA++;
}
Since this is my first programming language im learning in so lost any and all help is apperciated!