Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37ea587

Browse files
committed
Java第十二天
1 parentecaf465 commit37ea587

File tree

63 files changed

+1069
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1069
-0
lines changed
2.24 MB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentrykind="src"path="src"/>
4+
<classpathentrykind="con"path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
5+
<classpathentrykind="output"path="bin"/>
6+
</classpath>

‎day12/code/day12_Scanner/.project‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>day12_Scanner</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.7
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.7
575 Bytes
Binary file not shown.
904 Bytes
Binary file not shown.
783 Bytes
Binary file not shown.
882 Bytes
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
packagecn.itcast_01;
2+
3+
importjava.io.InputStream;
4+
importjava.util.Scanner;
5+
6+
/*
7+
* Scanner:JDK5以后,用于帮助我们实现键盘录入数据的。
8+
*
9+
* 构造方法:
10+
* public Scanner(InputStream source)
11+
*/
12+
publicclassScannerDemo {
13+
publicstaticvoidmain(String[]args) {
14+
// 创建键盘录入对象
15+
// Scanner sc = new Scanner(System.in);
16+
17+
// public Scanner(InputStream source)
18+
19+
// System类下有这样的一个成员变量
20+
// public static final InputStream in;
21+
// InputStream is = System.in;
22+
23+
// 假如Demo类下有一个变量
24+
// public static final int x;
25+
// public static final Student s;
26+
// int y = Demo.x;
27+
// Student student = Demo.s;
28+
29+
// InputStream is = System.in; //子类对象
30+
// Scanner sc = new Scanner(is);
31+
32+
Scannersc =newScanner(System.in);
33+
}
34+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
packagecn.itcast_02;
2+
3+
importjava.util.Scanner;
4+
5+
/*
6+
* 成员方法:
7+
* hasNextXxx():判断下一个输入项是不是指定的数据类型
8+
* nextXxx():获取该类型的数据
9+
*
10+
* 注意:
11+
* 键盘录入数据,需要的是int类型,我却给了一个字符串。
12+
* 在控制台就提示:InputMismatchException输入不匹配异常。
13+
*
14+
*/
15+
publicclassScannerDemo {
16+
publicstaticvoidmain(String[]args) {
17+
Scannersc =newScanner(System.in);
18+
19+
System.out.println("请输入一个整数:");
20+
21+
if (sc.hasNextInt()) {
22+
intnumber =sc.nextInt();
23+
System.out.println(number);
24+
}
25+
26+
System.out.println("over");
27+
}
28+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp