Files
Obsidian-Main/03. Programming/Kotlin/class.md
Awin Huang 077ee029bc vault backup: 2022-09-30 11:14:07
Affected files:
.obsidian/workspace
03. Programming/Kotlin/class.md
2022-09-30 11:14:07 +08:00

11 lines
418 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Kotlin中的class由class關鍵字開始一個簡單的class如下
class VerySimple {
}
如果需要constructor的話則在class名稱之後加入所需的參數如下
class VerySimple(para1: Int, para2: String ) {
}
加在constructor中的參數會自動變成class的「成員變數」如果在參數前面加上private則會成「私有成員變數」也就是無法被外部所存取。