Home > Java > javaTutorial > body text

java keyboard entry

怪我咯
Release: 2017-06-27 11:20:44
Original
2532 people have browsed it

Keyboard entry (Java):

1. Guide package

Format

     import java.util.Scanner;
Copy after login

  Position

                                                                                                                                                                                                                                                 . .Create keyboard input object

       Format

     Scanner sc = new Scanner(System.in);
Copy after login

  3. Obtain data through the object

       Format

            int x = sc.nextInt();
Copy after login

import java.util.Scanner;

class ScannerDemo {
     public static void main(String[] args) {
          //创建键盘录入数据对象
          Scanner sc = new Scanner(System.in);
          int x = sc.nextInt();
     }
}
Copy after login

The above is the detailed content of java keyboard entry. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template