From 879d207e0d0915a36e48e4abc668bf8751347a1f Mon Sep 17 00:00:00 2001 From: BadOfficer Date: Wed, 31 May 2023 10:49:23 +0300 Subject: [PATCH] update lab5 --- .../_02_Бондаренко_Тарас_Андрійович/lab5/Sentence.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IO_24/_02_Бондаренко_Тарас_Андрійович/lab5/Sentence.java b/src/IO_24/_02_Бондаренко_Тарас_Андрійович/lab5/Sentence.java index acf2f9e..247157f 100644 --- a/src/IO_24/_02_Бондаренко_Тарас_Андрійович/lab5/Sentence.java +++ b/src/IO_24/_02_Бондаренко_Тарас_Андрійович/lab5/Sentence.java @@ -25,19 +25,19 @@ public class Sentence { allWords.append(sentence).append(" "); } - String[] words = allWords.toString().split("\\W+"); // Remove punctuation marks + String[] words = allWords.toString().split("\\W+"); HashSet uniqueWords = new HashSet<>(); for (String word : words) { - if (!word.isEmpty()) { // Ignore empty words - uniqueWords.add(word.toLowerCase()); // Convert word to lowercase and add to HashSet + if (!word.isEmpty()) { + uniqueWords.add(word.toLowerCase()); } } String[] uniqueSortedWords = uniqueWords.toArray(new String[0]); - Arrays.sort(uniqueSortedWords); // Sort unique words by the first letter + Arrays.sort(uniqueSortedWords); for (String word : uniqueSortedWords) { System.out.println(word);