import java.util.*; public class NonduplicateWords { public static void main(String[] args) { String text = "Testing. I have a testing text. Have a great day"; TreeSet<String> set = new TreeSet<String>(); String[] words = text.split("[ \n\t\r.,;:!?(){}]"); for (int i = 0; i < words.length; i++) { String value = words[i].toLowerCase(); if (words[i].length() > 0) set.add(value); } for (Object element: set) System.out.println(element.toString() + " "); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)