When I was learning Java programming, I wanted to let the value of a variable be received from the keyboard input. Usually in DOS running effect is very intuitive, then I in editplus this development tool can also input, EditPlus is with console. When you run the Java program, the compilation information and the window that runs the results are called the console.
☆ Preparation Work
①, computer systems Build a Java Development environment (JDK environment configuration)
②,editplus has configured the compilation and runtime environment for Java programs
③,editplus basic settings have been set (temporary cache files, fonts, etc.). )
☆ Write Program (encoding)
①, open editplus Create a file named Demo01.java under the Practice folder
②, in the first line, introduces the tool class scanner provided by the JDK, which is primarily responsible for scanning content from the console.
Introduced code format: import Java.util.Scanner;
③, when using scanner in a class, instantiate a scanner (build a scanner)
Code format: Scanner sc = new Scanner (system.in);
④, find the JDK API to find the right scanner within the topic, as required by the topic
Nextint (): Receive integer
Nextdouble (): Receive double-precision decimals
Next (): receives continuous content, regardless of numeric characters, when the string is processed
Next (): Receives a row, does not distinguish between the space punctuation or anything, all as string processing.
⑤, code writing style (the example in the implementation of the input any two number of the addition operation)
650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160816/3103d71599fe4426941f34c3d770d9f1_th.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>
Note: The printout format can be defined on its own. But all follow the pattern of using strings.
☆ Compile and run
Compile click on the Tools menu to select the Javac menu item, or the direct combination of CTRL + 1, you will see the console prompt, there is a problem, go to modify, no problem. You can perform the run.
Run the Point Tools menu, select the Java menu item, or directly combine CTRL + 2, and you can see the console output running results. If there is a problem, go to debug.
☆ Console Input
When we finish writing the program, compile without problems, and then when running the Java program, we are in the console: Right-click, select Keyboard Input in the pop-up menu (Keyboard input ...) This one, a form will pop up at this point.
650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160816/98d729d9365c4d94a421661db3636ef1.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>
In this dialog box, enter the integer you want to enter. then click OK. Then each receive parameter is similar to the Operation method, enter the parameters and click OK. You will then see the results of the console output.
Code written in EditPlus can also be compiled and run directly in DOS, but this involves some DOS command operations.
650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160816/f796c52bd7974dbebad7b8b3fae0eb58_th.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>
☆ PostScript
The EditPlus console does not display the input number, which is a bug in the software
Generally we will be receiving first print, then participate in program operation
The friendly tip is a good guide to the program runner, and if nothing else runs your program and doesn't know what to do.
Technology sharing: www.kaige123.com
This article from the "11247808" blog, reproduced please contact the author!
When EditPlus encounters Java's scanner