官术网_书友最值得收藏!

Classes

To declare a class, we use a class keyword, exactly like in Java:

class Player {
}

There's no new keyword in Kotlin. The instantiation of a class simply looks like this:

// Kotlin figured out you want to create a new player
val p = Player()

If the class has no body, as in this simple example, we can omit the curly brackets:

class Player // Totally fine
主站蜘蛛池模板: 万山特区| 古丈县| 盖州市| 闻喜县| 拉萨市| 永修县| 铜陵市| 眉山市| 永登县| 三门峡市| 鱼台县| 当雄县| 葫芦岛市| 望江县| 土默特左旗| 遂宁市| 兴国县| 甘谷县| 棋牌| 洛南县| 白水县| 莫力| 高陵县| 团风县| 连山| 隆子县| 乐业县| 衡东县| 廊坊市| 寿宁县| 中山市| 临桂县| 静海县| 宝坻区| 民勤县| 扶风县| 旅游| 辽源市| 三河市| 炎陵县| 阿拉善右旗|