I am writing a Java hangman game where the user enters a letter guess and then guesses in which spaces the letter is in. For easy mode, the user can guess 4 spaces. The user must guess 4 spaces with a space between the numbers.
My question is, I have String guesses = keyboard.next(); but the issue I am having issue with is, how can I get the number that's at index 0, 2, 4, and 6? I am not allowed to use int space1 = keyboard.nextInt(); and so on. I have to use a string. So how can I extract the numbers at indices 0, 2, 4, and 6 from the string guesses?
P.S. I am not allowed to use arrays or the string builder class.
String.substringdocs.oracle.com/javase/7/docs/api/java/lang/…