Hey everyone I am new to coding and I want to learn more. I have tried different approches from other codes I have seen relating to this problem. The error that displays is something I have no idea how to fix. Below is my code it keeps giving me an error message.
import java.util.Scanner;
public class ParseStrings {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String userInput = "";
boolean inputDone = false;
while (!inputDone) {
System.out.print("Enter input string: \n");
userInput = scnr.nextLine();
if (userInput.equals("q")){
System.out.println("First word: " + userInput);
inputDone = true;
} else {
String[] userArray = userInput.split(",");
System.out.println("First word: " + userArray[0]);
System.out.println("Second word: " + userArray[1]);
System.out.println();
}
}
return;
}
}
My inputs are: Golden , Monkey Washington,DC Jill, Allen Enter input string: q
I am sorry if this is an easy fix.