-1

ユーザー入力を受け取ることができることは知って Scanner scanner = new Scanner(System.in);いますが、使用方法を尋ねることはできますか?それらを置くたびに、NetBeansはコンソールにユーザー入力を要求せずにそれを実行します。ユーザー入力を使用するための構成方法を尋ねたいだけですか?

もちろん、nextLineとnextIntを配置します。netBeansを停止させる方法を尋ねて、入力を求めます。

4

3 に答える 3

1

output下部に (window)と呼ばれるものが表示されます --> 入力を求めるプロンプトが表示されます。

そこで出力ウィンドウが利用できない場合は、gotoWindow menu--> Select output--> ouput

(また)Ctrl+4

于 2012-12-05T16:38:50.307 に答える
0

because you need to give a message before like this.

// this is your input object

Scanner input = new Scanner(System.in);

 // give massage 
System.out.println("give some in put");

 // to get input where you want
String input = input.nextline();

 system.out.println(""+input);
于 2012-12-05T16:40:47.220 に答える
0

It is quite simple. Here is an example for you.

public class Test {
    public static void main(String[] args) [
        Scanner INPUT = new Scanner(System.in);
        int i;

        System.out.print("Enter number: "); // This displays to the user to enter a number.
        i = INPUT.nextInt(); // Sets i equal to the user input.
    }
}

If you are using a string for input try INPUT.nextLine();.

You can find more info on it here: http://download.oracle.com/javase/1,5,0/docs/api/java/util/Scanner.html

于 2012-12-05T16:41:04.107 に答える