Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Implementing BrowserHistory | Advanced Data Structures in Java
Java Data Structures
course content

Course Content

Java Data Structures

Java Data Structures

1. Fundamental Data Structures in Java
2. Advanced Data Structures in Java
3. Mastering Map in Java
4. Advanced Java Features and Techniques

book
Challenge: Implementing BrowserHistory

Task

In the previous chapter, you implemented a system with two buttons, forward and backward, using the obsolete Stack data structure, which is not recommended for use in modern Java development.

In this chapter, your task is to recall the logic you used to implement the BrowserHistory class and implement it using the Deque data structure.

Try not to peek at the previous chapter and complete this task on your own—so to speak, "recode the code." This is also excellent practice with GitHub, which will be beneficial for you.

An interface with all the methods has been created in the code available on GitHub via the link below. Your task is to create a class implementation and implement this interface by overriding all its methods.

Once you finish, run the tests that I have written for you; it will automatically check your solution.

You can also perform intermediate tests in the main class. Overall, I rely on your honesty and independence. A true programmer should be able to understand code independently!

  • Start by creating three attributes in this class: backStack, forwardStack, and currentUrl.
  • Next, use an auto-generator to create the constructor for this class.
  • Use the implements keyword and override all methods of the BrowserHistory interface.
  • In the methods, utilize the Deque or Stack methods you've learned earlier. Remember that Deque is a modern and superior replacement for the Stack data structure.
java
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 5
We're sorry to hear that something went wrong. What happened?
some-alt