Question
Implement a method that returns a Set of all of the unique letters (including spaces) in a String. Letters are returned as strings with length
Implement a method that returns a Set of all of the unique letters (including spaces) in a String. Letters are returned as strings with length 1. Call this method: makeSet
a. Parameter(s): a String b. Returns: a Set c. Ex. Input: "COMP 271 and sets". Output: [" ", "1", "2", "7", "C", "M", "O", "P",
"a", "d", "e", "n", "s", "t"]. The space is in the first position. You then have the digits and characters in sequential order.
Finish the code below:
Main Method:
import java.util.*; class Main { public static void main(String[] args) { System.out.println("Hello world!"); String x = "COMP 271 and sets"; System.out.println(makeSet(x)); }
//Add your code here
}
Resources:
1. https://www.youtube.com/watch?v=_aEks9LECaU
2. https://www.youtube.com/watch?v=At_HaClrey0
3. https://www.youtube.com/watch?v=WcKI8XdtZfo
Step by Step Solution
3.53 Rating (143 Votes )
There are 3 Steps involved in it
Step: 1
You can implement the makeSet method as follows java import javautil class ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started