# 初學常見錯誤 ＆ 提高可讀性

針對常見的錯誤列出以下幾點讓初學者做參考

### 一、常見錯誤

```
package ch01;

public class class01 {

	public static void main(String[] args) {

		 System.out.println("Hello Java!");

	}
}
```

1. System 的 **S** 要記得大寫
2. 注意 System . out . print 之間是點「 . 」並非逗號「 , 」
3. 程式碼結束會跟著分號「；」
4. ｛｝大括號結尾的，不需要分號 「；」
5. public static void main(String \[]args){}\
   public static void main(String args\[]){}\
   兩者的意思是相同的
6. 注意呼叫的單字拼寫是否正確
7. 注意程式碼英文為半形，並非全形
8. 括號 或 大括號 都是成對出現的
9. 類別class 與函數method 都是使用大括號 ｛｝將其內容包住
10. class 名稱命名方式不包含 「 . 」或「 – 」 的形式出現\
    如：ch01.2  ch01-2\
    建議可以使用底線符號 「 \_ 」\
    如：ch01\_2

### 二、提高可讀性

* 適當的加上註解「 // 」到該行結束，\
  或使用「 /\*」與「 \*/」這兩個符號之間可跨越多行建立註解
* 變數名稱或是類別名稱，命名時盡量使用有意義的名稱，\
  配合該內容作命名
* 盡量一行一個敘述， （一行出現一個分號「；」）\
  若敘述被括號刮著除外，如 for (int i=1; i<10;i++)
* 適當的將同一區塊的程式碼敘述做「縮行」整理
* 必要時，適當的空行也可以提高可讀性


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://java.4-x.tw/newbie/java-003.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
