I just need to find a way to validate the input so that if the first array input (hometeam) is missing, it displays the message "no home team entered".
Sample input = "Everton : Liverpool : 1 : 1" missing hometeam example " : Liverpool : 1 : 1"
As you can see, my attempt is below, I can't think how to work this out:
if (stats.get(i)[0] == null){
System.out.println("no home team name entered");
                }
Here is my full code:
public static void main(String args[]) {
         Scanner sc = new Scanner(System.in);
            ArrayList<String[]> stats = new ArrayList<>(); //initialize a container to hold all the stats
            System.out.println("please enter match results:");
            while(sc.hasNextLine())
            {
                String input = sc.nextLine();
                String[] results = input.split(" : ");
                if(results.length == 4)
                {
                    stats.add(results);
                }
                else if(input.equals("stop"))
                    break;
                else
                    System.out.println("Error reading input");
            }//end of while
            for(int i = 0; i < stats.size(); i++)
            {
                if (stats.get(i)[0] == null){
                    System.out.println("no home team name entered");
                }
                try{
                    System.out.println(stats.get(i)[0] + " " + Integer.valueOf(stats.get(i)[2]) + " : " +
                            Integer.valueOf(stats.get(i)[3]) + " " + stats.get(i)[1]);
                }catch (Exception e) {
                    //do nothing with any invalid input
                }
            }
}
 
     
     
     
    