Question: TreeSet Given variables ( a , b , c ) , and ( d ) , perform the following steps: -
TreeSet
Given variablesabcanddperform the following steps:
Declare a TreeSet of Integer called numbers.
quadUse a method to add each value from the provided variablesabcanddto the numbers TreeSet.
Print the elements of the TreeSet numbers to the console, preceded by the string "Before:in your print statement.
quadUse the clearmethod to remove all the elements from the TreeSet called numbers.
Print the elements again after the TreeSet numbers is cleared. Add the string "After:to the beginning of your print statement
import java.io;
import java.util.;
public class CodingQuestion
public static void mainStringargs
Scanner innew ScannerSystemin;
int abcd;
mathrmamathrminoperatornamenextnt;
binnextInt;
cinnextInt;
dinnextInt;
DO NOT CHANGE THE CODE ABOVE THIS LINE
WRITE YOUR CODE HERE
DO NOT CHANGE THE CODE BELOW THIS LINE
STDOUT
Expected STDOUT
Before:
After:
TreeSet
Given variables a b c and d perform the following steps:
Declare a TreeSet of Integer called numbers.
quad Use a method to add each value from the provided variables a b c and d to the numbers TreeSet.
Print the elements of the TreeSet numbers to the console, preceded by the string "Before: in your print statement.
quad Use the clear method to remove all the elements from the TreeSet called numbers.
Print the elements again after the TreeSet numbers is cleared. Add the string "After: to the beginning of your print statem
import java.io;
import java.util.;
public class CodingQuestion
public static void mainString args
Scanner in new ScannerSystemin;
int a b c d;
mathrmamathrminoperatornamenextnt;
b innextInt;
c innextInt;
d innextInt;
DO NOT CHANGE THE CODE ABOVE THIS LINE
WRITE YOUR CODE HERE
DO NOT CHANGE THE CODE BELOW THIS LINE
STDOUT
Expected STDOUT
Before:
After:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
