Help us understand the problem. What is going on with this article?

java Scannerループ入力

More than 1 year has passed since last update.

この記事の目的

 いつも忘れるので自分用メモ

内容

 JavaでScannerで入力させて、希望の数値、文字列以外が入力されるまで入力ループしたい。例外処理は考えないでとりあえず処理だけのメモ。

コード

rupe.java
Scanner scan = new Scanner(System.in);
while(true){
  int num = scan.nextInt();
  switch(num){
    case // 入力してほしい数値:
      // 処理内容
      break;
    default:
      continue;
  }
  break;
}
No_LINE
第二新卒。前職販売職の言葉通りの未経験。なんとかエンジニアに転職したい。勉強に利用させていただきます。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした