Question: Modify the code to send a string This is a string instead of date and time // Channel.java public interface Channel { public void send(E
Modify the code to send a string "This is a string" instead of date and time
// Channel.java
public interface Channel{ public void send(E item); public E receive(); }
//MessagQueue.java
import java.util.Vector; public class MessageQueueimplements Channel { private Vector queue; public MessageQueue() { queue = new Vector (); } public void send(E item) { queue.addElement(item); } public E receive() { if (queue.size() == 0) return null; else return queue.remove(0); } }
//Test.java
import java.util.Date; public class Test { public static void main(String[] args) { Channel mailBox = new MessageQueue(); mailBox.send(new Date()); Date rightNow = mailBox.receive(); System.out.println(rightNow); } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
