提交 25b967fa 编写于 作者: M Mars Liu

add const sample

上级 660070d5
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"keywords": ["输出", "main", "程序入口"],
"children": [],
"export": ["HelloWorld.json"]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"keywords": ["输出", "循环", "for"],
"children": [],
"export": ["app.json"]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"keywords": ["变量", "赋值", "定义"],
"children": [],
"export": ["swap.json"]
"export": ["vars.json", "swap.json"]
}
\ No newline at end of file
{
"type": "code_options",
"author": "刘鑫",
"source": "vars.md",
"exercise_id":"f990d6473c1c4b0c8947c27681c8f476"
}
\ No newline at end of file
# 变量定义
以下变量定义哪个是错误的
## 答案
```java
x = new Int(100)
```
## 选项
### 常规定义
```java
String line = "一个字符串变量";
```
### 变量可以没有初始值
```java
float x;
```
### 局部变量在通常情况下可以自动推导类型
```java
var x = 3.14;
```
......@@ -2,5 +2,5 @@
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [],
"export": []
"export": ["solidity.json"]
}
\ No newline at end of file
{
"type": "code_options",
"author": "刘鑫",
"source": "solidity.md",
"exercise_id":"45bc14d503364f999f98e5d2faad2fec"
}
\ No newline at end of file
# 常量
下面哪个常量定义是错的?
## 答案
```java
const int value = 100;
```
## 选项
### 可以用于局部变量
```java
final int value = 100;
```
### 可以用于 public 成员
```java
public final int value = 100;
```
### 可以用于静态成员
```java
public static final int value = 100;
```
### 可以用于自动类型
```java
final var x = 100;
```
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册