提交 d758f05b 编写于 作者: W wizardforcel

2020-07-08 21:49:43

上级 226808f8
......@@ -302,6 +302,6 @@ Using nextBigDecimal(): 9.55555
He is 22
```
在这种情况下,扫描器对象将读取整行并将字符串分成标记:**He** ”,“ **为**”和“ **22**。 然后,对象遍历每个令牌,并使用其不同方法读取每个令牌。
在这种情况下,扫描器对象将读取整行并将字符串分成标记:`He``is``22 `。 然后,对象遍历每个令牌,并使用其不同方法读取每个令牌。
**注意**:默认情况下,空格用于划分令牌。
\ No newline at end of file
......@@ -98,7 +98,7 @@ double getPiValue() {
在 Java 中,lambda 主体有两种类型。
**1.具有单个表达式的身体**
**1.具有单个表达式的正文**
```java
() -> System.out.println("Lambdas are great");
......@@ -106,7 +106,7 @@ double getPiValue() {
这种类型的 lambda 主体称为表达式主体。
**2.由代码块组成的主体。**
**2.由代码块组成的正文**
```java
() -> {
......
......@@ -51,7 +51,7 @@ ArrayList of String: [Four, Five]
ArrayList of Double: [4.5, 6.5]
```
在上面的示例中,我们使用了相同的`ArrayList`类来存储`Integer``String``Double`类型的元素。 由于 **Java Generics** 的缘故,这是可能的。
在上面的示例中,我们使用了相同的`ArrayList`类来存储`Integer``String``Double`类型的元素。 由于 **Java 泛型**的缘故,这是可能的。
在这里,请注意这行,
......
......@@ -86,7 +86,7 @@ D D D D
E E E E E
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -120,7 +120,7 @@ public class Pattern {
*
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -150,7 +150,7 @@ public class Pattern {
1
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -176,7 +176,7 @@ public class Pattern {
* * * * * * * * *
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -199,7 +199,7 @@ public class Pattern {
5 6 7 8 9 8 7 6 5
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -222,7 +222,7 @@ public class Pattern {
*
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -247,7 +247,7 @@ public class Pattern {
1 5 10 10 5 1
```
**Source Code**
**源代码**
```java
public class Pattern {
......@@ -274,7 +274,7 @@ public class Pattern {
7 8 9 10
```
**Source Code**
**源代码**
```java
public class Pattern {
......
......@@ -102,7 +102,7 @@ first = first - second;
first = 12.0f - 24.5f
```
然后,我们只需在**后面加上**`second`(`24.5f`)-首先计算(`12.0f - 24.5f`)即可交换该数字。
然后,我们只需在`first`(`12.0f - 24.5f`)**后面加上**`second`(`24.5f`),即可交换该数字。
```java
second = first + second;
......
......@@ -4,9 +4,9 @@
#### 在此程序中,您将学习使用 Java 从给定文件的内容创建字符串的不同技术。
从文件创建字符串之前,我们假设在 **src** 文件夹中有一个名为 **test.txt** 的文件。
从文件创建字符串之前,我们假设在`src`文件夹中有一个名为`test.txt`的文件。
这是 **test.txt** 的内容
这是`test.txt`的内容
```java
This is a
......
......@@ -4,9 +4,9 @@
#### 在此程序中,您将学习将 Java 文本附加到现有文件的各种技巧。
在将文本追加到现有文件之前,我们假设在 **src** 文件夹中有一个名为 **test.txt** 的文件。
在将文本追加到现有文件之前,我们假设在`src`文件夹中有一个名为`test.txt`的文件。
这是 **test.txt** 的内容
这是`test.txt`的内容
```java
This is a
......@@ -36,7 +36,7 @@ public class AppendFile {
}
```
运行该程序时, **test.txt** 文件现在包含:
运行该程序时,`test.txt`文件现在包含:
```java
This is a
......
......@@ -28,7 +28,7 @@ public class CompareStrings {
Equal
```
在上面的程序中,我们有两个字符串`style``style2`。 我们仅使用相等运算符(`==`)比较两个字符串,这会将值 **Bold****Bold** 进行比较,并输出 **Equal**
在上面的程序中,我们有两个字符串`style``style2`。 我们仅使用相等运算符(`==`)比较两个字符串,这会将值`Bold``Bold`进行比较,并输出`Equal`
* * *
......@@ -56,7 +56,7 @@ When you run the program, the output will be:
Equal
```
在上面的程序中,我们有两个字符串`style``style2`都包含相同的世界 **Bold**
在上面的程序中,我们有两个字符串`style``style2`都包含相同的全局`Bold`
但是,我们使用了`String`构造器来创建字符串。 要在 Java 中比较这些字符串,我们需要使用字符串的`equals()`方法。
......@@ -64,7 +64,7 @@ Equal
另一方面,`equals()`方法比较字符串的值是否相等,而不是对象本身。
如果改为将程序更改为使用等号运算符,则会显示**不等于**,如下所示。
如果改为将程序更改为使用等号运算符,则会显示`Not Equal`,如下所示。
* * *
......
......@@ -101,12 +101,12 @@ File file = new File("Tutorial\\directory");
The new directory is created.
```
**However, if the directory already exists**, we will see this message.
**但是,如果目录已经存在**,我们将看到此消息。
```java
The directory already exists.
```
在这里,如果**教程**目录不存在,则`mkdirs()`方法也会创建**教程**目录以及**目录**
在这里,如果`Tutorial`目录不存在,则`mkdirs()`方法也会创建`Tutorial`目录以及`directory`
**注意**:在指定路径时,我们使用了**双反斜杠**。 这是因为`\`字符在 Java 中用作**转义字符**。 因此,第一个反斜杠用作第二个的转义字符。
\ No newline at end of file
......@@ -74,7 +74,7 @@ file.renameTo(newFile);
The name of the file is changed.
```
**如果操作无法成功**,则会显示以下消息。
**如果操作成功**,则会显示以下消息。
```java
The name cannot be changed.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册