Design Browser History - Java Solution using Doubly Linked List
\n\n# Code\n\npublic class ListNode{\n  ListNode next;\n  String data;\n  ListNode prev;\n  public ListNode(String data) {\n        this.data = data;\n    }\n}\
\n\n# Code\n```\npublic class ListNode{\n  ListNode next;\n  String data;\n  ListNode prev;\n  public ListNode(String data) {\n        this.data = data;\n    }\n}\nclass BrowserHistory {\n    ListNode dummy,hehe;\n    public BrowserHistory(String homepage) {\n     dummy=new ListNode(homepage); \n    }\n    \n    public void visit(String url) {\n      ListNode temp=new ListNode(url);\n      dummy.next=temp;\n      temp.prev=dummy;\n      dummy=temp;  \n    }\n    \n    public String back(int steps) {\n        while(steps--!=0 && dummy.prev!=null)\n        {\n            dummy=dummy.prev;\n        }\n        return dummy.data;\n    }\n    \n    public String forward(int steps) {\n        while(steps--!=0 && dummy.next!=null)\n        {\n            dummy=dummy.next;\n        }\n        return dummy.data;\n    }\n}\n\n/**\n * Your BrowserHistory object will be instantiated and called as such:\n * BrowserHistory obj = new BrowserHistory(homepage);\n * obj.visit(url);\n * String param_2 = obj.back(steps);\n * String param_3 = obj.forward(steps);\n */\n```
['Java']