commit 285ae98 code中文原文

On Input in Java

Author
Yujia Lin
Date
Reading time
1 min read

Translated from Chinese by Claude. Read the original

This is the simplest way to read input. Here’s the source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.*; //引用含有Scanner类的包

public class InputNumber

{

public static void main(String args[])

{

Scanner numberInput=new Scanner(System.in); //定义一个扫描类 numberInput

int Number=numberInput.nextInt(); //将值赋给整型数Number变量

System.out.println(Number); //输出输入的Number的值

}

}

I spent the whole day in the reading room today and it felt great. I got a lot done. Right now I’m mainly studying Java and C. C is my main course, and Java is secondary for now. I’ll write some short posts about them from here on.

Esc

Keyboard shortcuts

Ctrl K /
Search and commands
j k
Next or previous post in a list
Enter
Open the selected post
h l
Older or newer post (on a post)
g h
Go to the log
g a
Go to the archive
g t
Go to tags
g s
Go to stats
t
Switch light or dark theme
r
Random post
?
Show this help