preload
五月 21

這裡只是展示一般的架構長什麼樣子,而不是每份程式碼都會長這樣。當然有些規則是一定要遵守的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
  comment
*/
 
// Declaring this file to be a package.
// All java source code belongs to some package.
// Only trivial, testing code does not declare a packge.
// When a source file does not declare a package, it is said be a “unnamed” package
package mary.games.sounds;
 
// load packages you need
import java.awt.Cursor;
import ...
...
 
// a bunch of class definitions
class MyClass1 {
    ...
}
 
class MyClass2 {
    ...
}
 
... // more classes
 
// The main class.
// The file name must be the same as this class name
class MyMainClass {
    public static void main(String[] args) {
        //body...
    }
}

Note:其中一個 class 的名字要和程式碼檔名相同,名字首字必須大寫。

ref: Java Tutorial: Printing a String

溫故知新

載入中…

歷史上的今天..

相關文章:

Leave a Reply