kotlin所谓高大上的委托属性理解
简书链接:kotlin所谓高大上的委托属性理解文章字数:484,阅读全文大约需要1分钟说实话,我java开发听到这个委托感觉高大上,没听过也不知道什么叫委托,现在 我感觉无非就是监听一个变量的set get调用。 类似java设置一个监听一样. 123456789101112131415161718192021222324252627282930313233343536fun main(args: Array<String>) { var hello: String by DelegateListener(); println("value ${hello}") hello = "xxxx"; println("value ${hello}") class DelegateClass { var fuck: String by DelegateListener(); } var...
kotlin类继承的演示
简书链接:kotlin类继承的演示文章字数:94,阅读全文大约需要1分钟 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859open class Person(name: String, age: Int) { var currentName = name; var age = age; init { "init call ${currentName} name:${name}" } fun hello() { println("hello method call my name is:${this.currentName} ,i'm ${this.age} years...
java单例转kotlin的表现
简书链接:java单例转kotlin的表现文章字数:55,阅读全文大约需要1分钟 java代码 123456789101112131415161718192021222324252627282930313233343536373839404142class TestStatic { private static final String TAG = "TestStatic"; private static TestStatic instance; private static TestStatic staticField; private TestStatic notStaticField; public static TestStatic getInstance() { if (instance == null) { synchronized (TestStatic.class) { if (instance ==...
泛型和继承演示
简书链接:泛型和继承演示文章字数:19,阅读全文大约需要1分钟 12345678910111213141516171819202122232425262728293031323334353637 open abstract class ParentTest<in T> { abstract fun hello(other: T): Int } open abstract class MyAB<T> : ParentTest<T>() { } class MyImp1 : MyAB<Double>() { override fun hello(other: Double): Int {// TODO("not implemented") //To change body of created functions use File | Settings | File...
kotlin更牛逼的转义类似swiftphp的某些代码块转义
简书链接:kotlin更牛逼的转义类似swiftphp的某些代码块转义文章字数:56,阅读全文大约需要1分钟里面任何字符都不会进行转义 12345val text = """ for (c in "foo")//\n print(c)"""println("kotlin的语法演示:${text}"); 那么转义则和java一样"hello \n world"或者普通的“\n \b”三个双引号开头和结尾中间可以插入任意字符.
kotlin遍历打印所有中文unicode或Ascii
简书链接:kotlin遍历打印所有中文unicode或Ascii文章字数:1005,阅读全文大约需要4分钟unicode实际上是ascii编码表的16进制 ,不过ascii码表只有127个,那么换行符Line feed \n转换为 unicode 也就是把\n对应的10进制 是 10 转换为16进制就是A,就是 \u000A 下面包含我的名字,哈哈 1println("i am line feed "+'\u000A'+" hello"+'\u7F57'+'\u6b63') 1234567891011121314 for(value in '0' .. 'z'){ println("ASCII CHAR ${value} DEC ${value.toByte()} HEX...
kotlin函数的举例
简书链接:kotlin函数的举例文章字数:51,阅读全文大约需要1分钟 1fun theAnswer() = 42 实际上等于 123fun theAnswer ():Int{return 42;} 类似java的switch逻辑分支函数 123456fun transform(color: String): Int = when (color) { "Red" -> 0 "Green" -> 1 "Blue" -> 2 else -> throw IllegalArgumentException("Invalid color param value")} 等于 1234567fun transform(color: String): Int {return when (color) { "Red" -> 0 "Green"...
让eclipse指定java环境运行,让eclipse3264同时运行
简书链接:让eclipse指定java环境运行,让eclipse3264同时运行文章字数:181,阅读全文大约需要1分钟如果你的eclipse.exe是32的此时默认的java环境变量是64的,但是又不想改成32的怎么办?直接打开会提示Failed to load the JNI shared library "XXXXXX\bin\..\jre\bin\server\jvm.dll" 这就是因为环境变量java版本和eclipse的版本不一致要不全部换成32 或者64,另外的方法...
windowcygwinc环境搭建
简书链接:windowcygwinc环境搭建文章字数:1177,阅读全文大约需要4分钟https://cygwin.com/install.html下载32 或者64位下载cygwin,在选择从internet下载的时候建议添加镜像站,提高下载速度http://mirrors.163.com/.help/cygwin.html选择从互联网安装, 在”User URL”处输入以下地址http://mirrors.163.com/cygwin/在搜索输入框搜索下面的东西然后点击Skip就会变成一个版本号, 而右边有一个bin,出现了一个x,再点击可能会出现版本号变化,甚至 New的字段会出现src源代码也勾选,然后最后又变成了skip,也就是不下载,按照国际惯例教程,都是选择带gun字样的进行安装,搜索的时候View选择full, gcc, gcc-core, gcc-g++, gcc-mingw-core, gcc-mingw-g++, make , gdb, binutils我就下载了gcc-core,gcc-g++, make...
碉堡了的kotlin扩展函数
简书链接:碉堡了的kotlin扩展函数文章字数:142,阅读全文大约需要1分钟 1234567891011121314151617181920//下面的方法存在于一个方法体中// var isContainQSSQ2 = "ddddd2".isContainerQSSQ()//there not isContainerExtandMehtod err// println("str is contain qssq:${isContainQSSQ2}");//在上面还没有定义之前是不能访问的,但是之后可以了。 var str:String ="hello "; fun String.isContainerQSSQ():Boolean{ println("isContainerQSSQ call this :${this}")//print str return...