Consider the following program:
import java.util.*; public class Main { public static void main(String []args) { String text = "<head>first program </head> <body>hello world</body>"; Set<String> words = new TreeSet<>(); try ( Scanner tokenizingScanner = new Scanner(text) ) { tokenizingScanner.useDelimiter("\\W"); while(tokenizingScanner.hasNext()) { String word = tokenizingScanner.next(); if(!word.trim().equals("")) { words.add(word); }/* w w w .j a v a 2 s .c o m*/ } } for(String word : words) { System.out.print(word + " "); } } }
Which one of the following options correctly provides the output of this program?
b)
TreeSet<String> orders the strings in default alphabetical ascending order and removes duplicates.
The delimiter \W is non-word, so the characters such as < act as separators.