Java.
Assume you want to add a new method public TgetLastMatch(T anEntry) to LinkedBagclass. The method returns a reference to the last data in a bagthat matches anEntry. If there is nomatch data, this method returns null. Note: assumefirstNode is a private data field inlinked list which references to first node.
Example: Let myBag contains stringobjects: “world”, “world”, “hello”, “world”,”abc”.
myBag.getLastMatch(“world”)returns a reference to the 4th data“world” in the bag.
public T getLastMatch(T anEntry)
{ //write your statements here. You may access data fieldsfirstNode here.
} // end of method
Expert Answer
An answer will be send to you shortly. . . . .