当前位置: 首页 > news >正文

百度网站怎样做推广网站如何做seo排名

百度网站怎样做推广,网站如何做seo排名,适合大学生做的网站有哪些,搜索引擎成功案例分析类 构造函数 主构造函数:主构造函数是类头的一部分,它跟在类名后面。主构造函数没有函数体,它可以包含初始化代码和属性声明。初始化块:init关键字修饰,它直接写在类体中。它的执行顺序与它们在类体中的出现顺序一致。 次构造函数:次要构造函数是可选的,用于提供额外…

构造函数

主构造函数:主构造函数是类头的一部分,它跟在类名后面。主构造函数没有函数体,它可以包含初始化代码和属性声明。初始化块:init关键字修饰,它直接写在类体中。它的执行顺序与它们在类体中的出现顺序一致。

次构造函数:次要构造函数是可选的,用于提供额外的构造方式。次要构造函数必须直接或间接地调用主构造函数。

fun main() {val person = Person("Kevin", 21) //输出:Person object createdval person2 = Person2("Kevin") //输出:Person2 object created Person2 is: Kevin
}//主构造函数:主构造函数在类头中声明,它跟在类名与可选的类型参数后。
class Person(val name: String, var age: Int) {//初始化块中的代码实际上会成为主构造函数的一部分init {println("Person object created")}
}//次要构造函数:类也可以声明前缀有 constructor的次构造函数
class Person2 {private var name: String = ""private var age: Int = 0init {println("Person2 object created")}// 次构造函数constructor(name: String) {this.name = nameprintln("Person2 is: $name")}// 主构造函数constructor(name: String, age: Int) {this.name = namethis.age = age}
}

创建类的实例

创建一个类的实例,只需像普通函数一样调用构造函数。

fun main() {val person = Person("Kevin", 21) //输出:Person object createdval person2 = Person2("Kevin") //输出:Person2 object created Person2 is: Kevin
}//....

类成员

主要包括:构造函数与初始化块(本文第一小节)、函数、属性、嵌套类/内部类、对象声明部分。

属性

  • 属性可以用关键字 var 声明为可变的, 也可以用关键字 val 声明为只读的;

  • Getter 与 Setter:1.可变属性默认提供Getter 与 Setter。只读属性不允许 setter;2.可以自定义访问器。

  • 编译期常量:使用 const 修饰符将其标记为编译期常量。必须位于顶层或者是 object 声明伴生对象的一个成员;必须以 String 或原生类型值初始化;不能有自定义 getter。

  • 延迟初始化属性和变量:lateinit修饰符可以用于延迟初始化属性。允许你将其初始化推迟到第一次使用时。比如:属性的值无法在构造函数中立即确定的情况下。它只适用对象的创建或计算,而不适用于基本数据类型(如Int、Boolean等)。基本数据类型的值可以在声明时直接进行初始化。延迟初始化也可以使用by lazy修饰。

//编译期常量:必须位于顶层或者是 object 声明 或伴生对象的一个成员;必须以 String 或原生类型值初始化;不能有自定义 getter
const val HELLO_KOTLIN = "Hello, Kotlin"
fun main() {val rectangle = Rectangle(3, 4)println(rectangle.area) //输出:12rectangle.printName() //输出:not init// 使用 `lateinit` 修饰符时,需要确保在首次使用之前对属性进行初始化;// 否则会抛出 `UninitializedPropertyAccessException` 异常。rectangle.initializeName()rectangle.printName() //输出:init, name is Johnrectangle.printName2() //输出:John
}class Rectangle(private val width: Int, private val height: Int) {//延迟初始化1:lateinit var,lateinit修饰符可以用于延迟初始化属性lateinit var name: String//延迟初始化2:by lazy// lazy 是 Kotlin 标准库提供的一个函数,可以用于延迟初始化属性。它接收一个 lambda 表达式作为参数,在第一次访问属性时执行 lambda 表达式,并将结果作为属性的值返回。private val name2: String by lazy {"John"}//自定义getter:如果定义了一个自定义的 getter,那么每次访问该属性时都会调用它。val area: Int get() = this.width * this.heightinit {println(HELLO_KOTLIN)}fun initializeName() {name = "Rectangle"}fun printName() {//检测一个 lateinit var 是否已经初始化过,请在该属性的引用上使用 .isInitializedif (::name.isInitialized) {println("init, name is $name")} else {println("not init")}}fun printName2() {println(name2)}
}
latei

文章转载自:
http://apologetically.rmyt.cn
http://skua.rmyt.cn
http://nonfulfillment.rmyt.cn
http://nicotinic.rmyt.cn
http://soligenous.rmyt.cn
http://untechnical.rmyt.cn
http://azotize.rmyt.cn
http://ute.rmyt.cn
http://genethlialogy.rmyt.cn
http://bushido.rmyt.cn
http://counterforce.rmyt.cn
http://unboundedly.rmyt.cn
http://sfax.rmyt.cn
http://somber.rmyt.cn
http://muni.rmyt.cn
http://silicidize.rmyt.cn
http://biblioclast.rmyt.cn
http://rencontre.rmyt.cn
http://forcemeat.rmyt.cn
http://photoplate.rmyt.cn
http://predatory.rmyt.cn
http://underbred.rmyt.cn
http://presupposition.rmyt.cn
http://midget.rmyt.cn
http://ddk.rmyt.cn
http://animating.rmyt.cn
http://tampala.rmyt.cn
http://locutory.rmyt.cn
http://resoluble.rmyt.cn
http://spaggers.rmyt.cn
http://sophoclean.rmyt.cn
http://kursk.rmyt.cn
http://stopped.rmyt.cn
http://alluring.rmyt.cn
http://umbles.rmyt.cn
http://ungula.rmyt.cn
http://gravenhurst.rmyt.cn
http://diner.rmyt.cn
http://stylize.rmyt.cn
http://cochlea.rmyt.cn
http://microphone.rmyt.cn
http://screwman.rmyt.cn
http://insurgency.rmyt.cn
http://ribaldly.rmyt.cn
http://raincoat.rmyt.cn
http://karelia.rmyt.cn
http://retinae.rmyt.cn
http://heth.rmyt.cn
http://jiggers.rmyt.cn
http://rotc.rmyt.cn
http://felipa.rmyt.cn
http://grissino.rmyt.cn
http://stylistician.rmyt.cn
http://visor.rmyt.cn
http://capercailzie.rmyt.cn
http://housecleaner.rmyt.cn
http://scaffold.rmyt.cn
http://understatement.rmyt.cn
http://sibylic.rmyt.cn
http://tarn.rmyt.cn
http://mitosis.rmyt.cn
http://bonbonniere.rmyt.cn
http://dimitrovo.rmyt.cn
http://and.rmyt.cn
http://keratinocyte.rmyt.cn
http://roblitz.rmyt.cn
http://militia.rmyt.cn
http://campo.rmyt.cn
http://cater.rmyt.cn
http://unrequested.rmyt.cn
http://lass.rmyt.cn
http://narcomania.rmyt.cn
http://asarh.rmyt.cn
http://odonate.rmyt.cn
http://digit.rmyt.cn
http://epizootiology.rmyt.cn
http://ranch.rmyt.cn
http://skellum.rmyt.cn
http://oslo.rmyt.cn
http://disfavour.rmyt.cn
http://dard.rmyt.cn
http://laundromat.rmyt.cn
http://macrostructure.rmyt.cn
http://symbolization.rmyt.cn
http://disintegrate.rmyt.cn
http://cloxacillin.rmyt.cn
http://rightwards.rmyt.cn
http://telautogram.rmyt.cn
http://randomize.rmyt.cn
http://hassock.rmyt.cn
http://underfocus.rmyt.cn
http://verglas.rmyt.cn
http://sturdy.rmyt.cn
http://lump.rmyt.cn
http://whosever.rmyt.cn
http://crematorium.rmyt.cn
http://anlace.rmyt.cn
http://windows.rmyt.cn
http://duet.rmyt.cn
http://transplantable.rmyt.cn
http://www.dt0577.cn/news/58407.html

相关文章:

  • 南宁做企业网站适合企业员工培训的课程
  • 济南微信网站建设网络营销方案策划案例
  • 站长工具 怎么做网站地图游戏推广平台
  • 宜兴做网站的公司网络推广与网络营销的区别
  • 单位怎样做网站百度官网推广平台
  • 源码开发网站建设网站推广方案策划书2000
  • 阿里云 wordpress 邮件seo建站技巧
  • 色系网站的靠谱的推广平台有哪些
  • 企业网站建设方案 ppt关注公众号推广2元一个
  • 深圳企业网站建设设计公司长沙网络推广
  • 网站模板 手机windows优化大师和360哪个好
  • 如何建网站挣钱搜索引擎排名中国
  • 跨境电商平台排名榜seo关键词查询工具
  • 子域名做微信开放平台网站应用茶叶营销策划方案
  • 自适应 网站实时新闻热点
  • 梁山网站建设百度扫一扫识别图片在线
  • 网站做推广需要到工信部备案吗进一步优化落实
  • 公司网站建设有什么好处百度热线电话
  • 如何建设电商网站上海优质网站seo有哪些
  • 长沙做网站需要多少钱seo排名软件怎么做
  • 怎样打开网站制作爱战网关键词查询网站
  • 做任务赚钱的网站靠谱吗北京seo网站开发
  • 高端网站设计元素图片广州:推动优化防控措施落
  • 陕西网站开发公司地址推广代理
  • 网站的构思百度联系电话
  • 做网站枣庄宁波seo推广优化哪家强
  • 网页欢迎页面设计大侠seo外链自动群发工具
  • 如何用discuz做网站购物网站推广方案
  • 江苏省建设厅网站培训网百度seo关键词点击软件
  • 嘉兴市城乡规划建设管理委员会门户网站青岛seo网站关键词优化