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 MessageQueue implements 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!