1
0

Java:基本语法(关键字、注释)

This commit is contained in:
周中平 2022-04-27 12:25:02 +08:00
parent b53ca5d67c
commit 40c1ce9229
No known key found for this signature in database
GPG Key ID: B1DF9DD42D8E00DC

View File

@ -82,5 +82,37 @@ int c = a++;
variable x = (expression) ? value if true : value if false
```
## 关键字
| 类别 | | | | | | | |
| -------------------- | -------- | ---------- | -------- | ------------ | ---------- | --------- | ------ |
| 访问控制 | private | protected | public | | | | |
| 类,方法和变量修饰符 | abstract | class | extends | final | implements | interface | native |
| | new | static | strictfp | synchronized | transient | volatile | |
| 程序控制 | break | continue | return | do | while | if | else |
| | for | instanceof | switch | case | default | | |
| 错误处理 | try | catch | throw | throws | finally | | |
| 包相关 | import | package | | | | | |
| 基本类型 | boolean | byte | char | double | float | int | long |
| | short | null | true | false | | | |
| 变量引用 | super | this | void | | | | |
| 保留字 | goto | const | | | | | |
## 注释
```java
public class HelloWorld {
/*
* 这是第一个Java程序
* 它将打印Hello World
* 这是一个多行注释的示例
*
*/
public static void main(String[] args){
// 这是单行注释的示例
/* 这个也是单行注释的示例 */
System.out.println("Hello World");
}
}
```