Question: What is the output when this java code is run: import java.util. * ; public class LabQuiz 1 { @SuppressWarnings ( unchecked )
What is the output when this java code is run:
import java.util.;
public class LabQuiz
@SuppressWarningsunchecked
public static void mainString args
A stack is given with the following inputs
Stack stack new Stack;
Random r new Random;
int max ;
int min ;
for int i ; i ; i
stack.pushrnextIntmax min min;
System.out.printlnyour origin stack";
System.out.printlnstack size is: stack.capacity;
Stack mystackStack stack.clone;
Stack mystackStack stack.clone;
Stack mystackStack stack.clone;
System.out.printlnSorted Stack";
System.out.printlnsortedStackmystack;
write a program to calculate the frequency of your stack with hashmap.
System.out.printlnprint out the results for your hashmap";
countmystackforEachkey value System.out.printlnkey value;
write a program to put your stack into a hashset.
System.out.printlnPrint out the results for your hashset";
HashSet hset stackTohashSetmystack;
System.out.printlnhset size is: hset.size;
public static Stack sortedStackStack stack
Stack sortedStack new Stack;
while stack.isEmpty
int temp stack.pop;
while sortedStack.isEmpty && sortedStack.peek temp
stack.pushsortedStackpop;
sortedStack.pushtemp;
return sortedStack;
public static HashMap countStack stack
HashMap hmap new HashMap;
for int num : stack
hmap.putnum hmap.getOrDefaultnum;
return hmap;
public static HashSet stackTohashSetStack stack
return new HashSetstack;
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
