- 最後登錄
- 2024-4-26
- 在線時間
- 0 小時
- 註冊時間
- 2007-6-1
- 閱讀權限
- 20
- 精華
- 0
- UID
- 1440669
- 帖子
- 70
- 積分
- 164 點
- 潛水值
- 12987 米
| 使用while(true)來做loop
然後判斷inpu是否為END- import java.util.Scanner;
- import javax.swing.*;
- public class AM {
- public static void main(String[] args) {
- while (true) {
- Scanner s = new Scanner(System.in);
- String s1 = JOptionPane.showInputDialog("Enter the Name ");
- if (s1 != null && s1.equals("END"))
- break;
- String s2 = JOptionPane.showInputDialog("Enter the age");
- if (s2 != null && s2.equals("END"))
- break;
- String output = "Name \t Age\n";
- JTextArea outputArea = new JTextArea();
- outputArea.setText(output);
- JOptionPane.showMessageDialog(null, outputArea, "result", JOptionPane.INFORMATION_MESSAGE);
- }
- }
- }
複製代碼 ... |
|