My code
Scanner reader = new Scanner(System.in);
String input = reader.nextLine();
Pattern regex = Pattern.compile("^(<[a-z][0-9]>)|(<[\\/][a-z][0-9]>)");
Matcher m = regex.matcher(input);
while (m.find()) {
listOfTags[i] = m.group();
i++;
}
checkOpeningTag = listOfTags[0];
checkClosingTag = listOfTags[1];
for(int k = 0;k<listOfTags.length;k++){
System.out.println("["+k+"] = "+listOfTags[k]);
}
When I try to input <h1></h1>
the output is
[0] = <h1>
[1] = </h1>
But when I input <h1><h1>
the output is
[0] = <h1>
[1] = null
Why is it storing null value?