020-005-001

Collections Utility: Word Operations

Easy

Problem Description

Collections Utility: Word Operations

In this problem, you will create a program that reads multiple words, counts the occurrence of the first word using Collections.frequency(), sorts all words alphabetically using Collections.sort(), and displays the results to standard output.

Learning Objective: Use Collections class frequency() and sort() methods

Collections class has convenient methods like frequency() counting element occurrences and sort() sorting list. Count how many times specific word appears with Collections.frequency(list, "word"), arrange list in alphabetical order with Collections.sort(list). Using these enables writing complex processing easily.

Input

Line 1: Number of words (integer, 1-10 words)
Lines 2~N+1: Word (string)

Output

Word Operations:
Original: [word 1] [word 2] ...
First Word Count: [occurrence count]
Sorted: [word] [word] ...

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
5
apple
banana
apple
orange
apple
Expected Output:
Word Operations:
Original: apple banana apple orange apple
First Word Count: 3
Sorted: apple apple apple banana orange
Normal case
Input:
4
cat
dog
bird
fish
Expected Output:
Word Operations:
Original: cat dog bird fish
First Word Count: 1
Sorted: bird cat dog fish

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining