Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么老是runtime error,请教一下,快疯了import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args)throws Exception { List list = new ArrayList(); list.add("http://www.acm.org/"); int pointer = 0; while(true) { Scanner cin=new Scanner(System.in); String str = cin.nextLine().trim(); if(str.equals("QUIT")) { return; } if(str.equals("BACK")) { if(pointer==0) { System.out.println("Ignored"); } else { pointer--; System.out.println(list.get(pointer)); } } if(str.equals("FORWARD")) { if(pointer==list.size()-1) { System.out.println("Ignored"); } else { pointer++; System.out.println(list.get(pointer)); } } if(str.startsWith("VISIT")) { String[] s = str.split(" "); list.add(++pointer,s[1]); System.out.println(s[1]); } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator