Implement class to add & getLast (JAVA8)
Anonymous User
149
Jul 07, 2020

Implement a IDSearchHistory class that supports the following operations:

  • add(id) -- adds a string ID to its collection
  • getLast() -- returns the last added ID from the collection

Example:

IDSearchHisory history = new IDSearchHistory();

history.add('AMZN');
history.add('TSLA');
history.getLast();       // returns 'TSLA'
history.add('AAPL');
history.getLast();       // returns 'AAPL'
Comments (3)