Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DPM;
- import java.util.*;
- public class Main {
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- ArrayDeque<String> web = new ArrayDeque<>();
- String line ;
- while (!"Home".equalsIgnoreCase(line = scan.nextLine())){
- if (!"back".equalsIgnoreCase(line)){
- web.push(line);
- System.out.println(line);
- }else {
- if (web.size()>1){
- web.pop();
- System.out.println(web.peek());
- }else {
- System.out.println("no previous URLs");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement