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

设计得很好的企业网站星宿网站建设

设计得很好的企业网站,星宿网站建设,企业手机网站建设精英,网站聊天室怎样做炫彩马甲kotlin获取属性属性获取器和设置器方法 (Properties Getter and Setter Methods) Variable having a class-level scope, declared inside the class body but outside the functions called property. 具有类级别范围的变量#xff0c;在类主体内部但在称为属性的函数外部声明…kotlin获取属性 属性获取器和设置器方法 (Properties Getter and Setter Methods) Variable having a class-level scope, declared inside the class body but outside the functions called property. 具有类级别范围的变量在类主体内部但在称为属性的函数外部声明。 Property can be declared with var(mutable) and val (read-only). 可以使用var(mutable)和val(只读)声明属性。 var/val propertyName: PropertyType property_initializer [getter] [setter] property_initializer, getter, and Setter are optional. property_initializergetter和Setter是可选的。 Getter and Setter Auto-Generated into the code. Getter和Setter自动生成到代码中。 Getter is used to get the value of properties and setter is used to set value of properties. Getter用于获取属性值而setter用于设置属性值。 val(read-only) type property does not allow setter. val(只读)类型属性不允许使用setter。 If we dont want public access of setter than declare it private. 如果我们不希望公开访问setter则将其声明为私有。 var name:String private set 程序以演示Kotlin中的属性Getter和Setter方法的示例 (Program to demonstrate the example of Properties Getter and Setter Methods in Kotlin) package com.includehelp // Declare class, class America{ // Declare property with initial value var city:String NewYork // Auto Generated getter and setter } // Declare class, class India{ // Declare property with initial value var city:String Delhi // define optional getter and setter get() field // Getter set(value) { // Setter fieldvalue } } // Declare class, define optional getter and setter class China{ // Declare property with initial value var city:String Wuhan // private setter, cant set value from outside the class private set // member function to set property fun setCity(city:String){ this.citycity } } // declare class, with customized getter and setter class Japan{ // Declare property with initial value var city:String Tokyo // Getter of property get() field.toUpperCase() //setter of Property set(value) { fieldModern City $value } } // Main function, entry Point of Program fun main(){ // create Instance val americaAmerica() america.cityAlsakaaa // access setter println(America : ${america.city}) // access getter // create Instance val indiaIndia() india.cityMumbai // access setter println(India : ${india.city}) // access getter // create Instance val chinaChina() // Try to access private setter, leads to compile time error // china.cityBeijing // Set City by calling member function china.setCity(Beijing) println(China : ${china.city}) // access getter // create Instance val japanJapan() india.cityQuoto // access setter println(Japan : ${india.city}) // access getter } Output: 输出 America : Alsakaaa India : Mumbai China : Beijing Japan : Quoto 翻译自: https://www.includehelp.com/kotlin/example-of-properties-getter-and-setter-methods.aspxkotlin获取属性
http://wiki.neutronadmin.com/news/196599/

相关文章:

  • 网站开发 荣誉资质做网站需要学习多久
  • 网站 标签导航网站运营效果分析怎么做
  • 网站怎么优化搜索引擎收录查询
  • 做销售网站的公司哪家最好重庆网站制作那家好
  • 做的网站怎么上传图片新媒体营销策划
  • 如何做公司网站百度推广上海快速网站建设
  • 同程网 网站模板色系网站.
  • 东莞公司注册多少钱青岛快速排名优化
  • 网站支付宝接口代码discuz做影视网站
  • 安徽网站建设方案开发php网站开发案例
  • 2018年静安区品牌网站建设h5商城
  • 外贸wordpress收款插件网站优化设计方案怎么做
  • 中国安能建设总公司网站义乌网站建设优化推广
  • 上社网站建设wordpress移动端菜单栏
  • 昆明网站建设推荐网站系统怎么建设
  • 怎么样增加网站权重网站布局有哪些
  • 招聘网站毕业设计wordpress 登陆logo
  • 咸宁做网站的公司那家便宜wordpress 文章间距
  • 企业建站域名网站建设盈利模式
  • 站长友情链接开发网站需要什么人员
  • 做暧暧小视频网站自己的网站怎么做关键词优化
  • 河北邯郸中考成绩查询时间抖音seo关键词优化
  • 手机如何制作游戏品牌seo培训
  • 上海短期网站建设培训哈铁工程建设公司网站
  • 网站建设与维护的认识wordpress加中文
  • 苏州建设造价信息网站网站制作系统哪个好
  • 网站源码如何安装网站后台管理系统模板下载
  • 网站管理有哪些不会做网站
  • 做移动端网站软件用linux做网站
  • 网站开发必备人员长沙建站工作室