_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › ConsoleEx2
|
|
[edit]
1 レ 螻給葦 蠍 #import java.util.*; public class ConsoleEx2 { static String[] argArr; public static void main(String[] args){ while(true){ String prompt = ">> "; System.out.print(prompt); Scanner lineStr = new Scanner(System.in); String lineInput = lineStr.nextLine(); lineInput = lineInput.trim().replaceAll("\\s+", " "); argArr = lineInput.split(" "); if(lineInput.equalsIgnoreCase("quit")){ System.exit(0); } else { for(int i=0;i<argArr.length;i++){ System.out.println(argArr[i]); } } } //while } //main } //class //intput : java ConsoleEx2.java aaa bbb ccc [edit]
2 LinkedList 蠍 #import java.util.*; public class ConsoleEx2 { static String[] argArr; static LinkedList q = new LinkedList(); static final int MAX_SIZE = 5; public static void main(String[] args){ while(true){ String prompt = ">> "; System.out.print(prompt); Scanner lineStr = new Scanner(System.in); String lineInput = lineStr.nextLine(); save(lineInput); lineInput = lineInput.trim().replaceAll("\\s+", " "); //argArr = lineInput.split(" +"); 螻 螳 企 . argArr = lineInput.split(" "); if(lineInput.equalsIgnoreCase("quit")){ System.exit(0); } else if (lineInput.equalsIgnoreCase("history")){ history(); } else { for(int i=0;i<argArr.length;i++){ System.out.println(argArr[i]); } } } //while } //main public static void save(String input){ if(input==null || "".equals(input)) return; q.add(input); if(q.size() > MAX_SIZE) q.remove(); } //save public static void history(){ int i=0; ListIterator it = q.listIterator(); while(it.hasNext()) System.out.println(++i + "." + it.next()); } } //class //intput : java ConsoleEx2.java aaa bbb ccc
鏤
|
螳 朱 蟲 豌 覺 讌朱 覦 螳襴襯 讌 . 覺 朱 覲旧蟒企 覯蟒 覿讌 . 襴 覿 ル瑚 企蟆 るジ 蟒覲企 蟆 朱 讌 . 蠏語 覓給牛 譴觜覃 願概 螻 訖企. 蠏碁り 襷る語襴 蠏語螻 讌 螳 蠍 谿襦螳 讌蠍 蟲 る 譴觜伎 蠏 リ鍵 襯 襷蟷 觸企 蟆企. (觜) |