3
ArrayList<String> history;5
public BrowserHistory(String homepage) {6
this.history = new ArrayList<>();11
public void visit(String url) {12
while (history.size() - 1 > current) { // delete forward history14
history.size() - 1); // which means delete everything beyond our current website20
public String back(int steps) {22
current = 0; // if we can't get enough back, we return first thing in our history23
else current -= steps; // if there will be no arrayindexoutofrange error, go back24
return history.get(current); // return current webpage27
public String forward(int steps) {28
// if we are going to move more than our arraylist, then we will return the last element29
if (steps + current >= history.size()) current = history.size() - 1;30
else current += steps; // if there will be no arrayindexoutofrange error, go forward!31
return history.get(current); // return the current webpage36
* Your BrowserHistory object will be instantiated and called as such: BrowserHistory obj = new37
* BrowserHistory(homepage); obj.visit(url); String param_2 = obj.back(steps); String param_3 =