├── code ├── RealmIssue │ ├── app │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── net │ │ │ │ │ └── println │ │ │ │ │ └── kotlin │ │ │ │ │ └── realm │ │ │ │ │ ├── PoKo.kt │ │ │ │ │ ├── User.kt │ │ │ │ │ ├── App.kt │ │ │ │ │ └── MainActivity.kt │ │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ ├── colors.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── layout │ │ │ │ │ └── activity_main.xml │ │ │ │ └── AndroidManifest.xml │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── gradle.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt14 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── Kt14 │ │ ├── src │ │ │ └── main │ │ │ │ ├── kotlin │ │ │ │ └── net │ │ │ │ │ └── println │ │ │ │ │ └── kt14 │ │ │ │ │ ├── Person.kt │ │ │ │ │ ├── ExtensionMethod.kt │ │ │ │ │ ├── Singleton.kt │ │ │ │ │ ├── Package.kt │ │ │ │ │ ├── CallInternalClass.kt │ │ │ │ │ ├── InternalClass.kt │ │ │ │ │ └── Overloads.kt │ │ │ │ └── java │ │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kt14 │ │ │ │ ├── CallPackageMethod.java │ │ │ │ ├── AccessToObject.java │ │ │ │ ├── CallExtenstionMethod.java │ │ │ │ ├── CallInternalClass.java │ │ │ │ ├── AccessToOverloads.java │ │ │ │ └── PersonMain.java │ │ └── build.gradle │ ├── kt14internal │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── kotlin │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kt14internal │ │ │ │ └── CallInternalClassKt.kt │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt14internal │ │ │ └── CallInternalClass.java │ ├── build.gradle │ └── gradlew.bat ├── Kt03 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ ├── kotlin │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kt03 │ │ │ │ └── User.kt │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt03 │ │ │ ├── Hello.java │ │ │ ├── HelloJava.kt │ │ │ └── HelloKotlin.kt │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt04 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt04 │ │ │ ├── ConsoleParam.kt │ │ │ └── ConsoleParamInJava.java │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt05 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt05 │ │ │ ├── ConsoleParam2.kt │ │ │ └── ConsoleParamInJava.java │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt06 │ ├── settings.gradle │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt06 │ │ │ ├── EnumInJava.java │ │ │ ├── Main.java │ │ │ └── SayHello.kt │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt08 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt08 │ │ │ ├── User.kt │ │ │ └── Service.kt │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt10 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ ├── kotlin │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kt10 │ │ │ │ └── kotlin │ │ │ │ ├── PlainOldSingleton.kt │ │ │ │ ├── LazyThreadSafeStaticInnerObject.kt │ │ │ │ ├── LazyThreadSafeSynchronized.kt │ │ │ │ ├── LazyNotThreadSafe.kt │ │ │ │ └── LazyThreadSafeDoubleCheck.kt │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt10 │ │ │ └── java │ │ │ ├── PlainOldSingleton.java │ │ │ ├── LazyNotThreadSafe.java │ │ │ ├── LazyThreadSafeStaticInnerClass.java │ │ │ ├── LazyThreadSafeSynchronized.java │ │ │ └── LazyThreadSafeDoubleCheck.java │ ├── build.gradle │ └── gradlew.bat ├── Kt11 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── kotlin │ │ │ └── net │ │ │ └── println │ │ │ └── kt11 │ │ │ ├── State.kt │ │ │ ├── Main.kt │ │ │ ├── PlayerCmd.kt │ │ │ └── Player.kt │ ├── build.gradle │ └── gradlew.bat ├── Kt12 │ ├── settings.gradle │ ├── result_singer_field_loss.json │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ ├── kotlin │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kt12 │ │ │ │ ├── GsonExt.kt │ │ │ │ ├── Data.kt │ │ │ │ ├── Main.kt │ │ │ │ └── Api.kt │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt12 │ │ │ └── Main.java │ ├── Program.cs │ ├── singer.json │ ├── result_songs.json │ ├── result_singer.json │ ├── build.gradle │ └── gradlew.bat ├── Kt13 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── kotlin │ │ │ └── net │ │ │ └── println │ │ │ └── kt13 │ │ │ ├── config │ │ │ └── Settings.kt │ │ │ ├── User.kt │ │ │ ├── module │ │ │ ├── GsonModule.kt │ │ │ ├── RxAdapterModule.kt │ │ │ ├── OkHttpClientModule.kt │ │ │ ├── CacheModule.kt │ │ │ ├── GsonConverterModule.kt │ │ │ ├── BaseUrlModule.kt │ │ │ └── RetrofitModule.kt │ │ │ ├── RESTFulComponent.kt │ │ │ └── Service.kt │ ├── build.gradle │ └── gradlew.bat ├── Kt15 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kt15 │ │ │ │ ├── NullSafetyJava.java │ │ │ │ ├── DataClass.java │ │ │ │ ├── NullSafetyAbsClass.java │ │ │ │ ├── Generics.java │ │ │ │ └── SAMInJava.java │ │ │ └── kotlin │ │ │ └── net │ │ │ └── println │ │ │ └── kt15 │ │ │ ├── ConcurrentRelated.kt │ │ │ ├── AccessDataClass.kt │ │ │ ├── NullSafety.kt │ │ │ ├── NullSafetySubClass.kt │ │ │ ├── GenericsInKt.kt │ │ │ └── SAMConversion.kt │ ├── build.gradle │ └── gradlew.bat ├── kt07 │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ ├── Resources │ │ │ └── input │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt07 │ │ │ └── Lambda.kt │ ├── build.gradle │ └── gradlew.bat ├── MyBatisIssue │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── libs │ │ └── mysql-connector-java-5.1.40-bin.jar │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── net │ │ │ │ └── println │ │ │ │ └── kotlin │ │ │ │ └── mybatis │ │ │ │ ├── db.properties │ │ │ │ ├── userinfo.sql │ │ │ │ ├── UserMapper.xml │ │ │ │ └── config.xml │ │ │ └── kotlin │ │ │ └── net │ │ │ └── println │ │ │ └── kotlin │ │ │ └── mybatis │ │ │ ├── annotations │ │ │ └── PoKo.kt │ │ │ ├── Main.java │ │ │ ├── UserMapper.java │ │ │ ├── User.kt │ │ │ ├── TestUnsafe.kt │ │ │ └── Main.kt │ ├── build.gradle │ └── gradlew.bat ├── Kt09 │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── net │ │ │ └── println │ │ │ └── kt09 │ │ │ └── Tailrec.kt │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── Kt02 │ └── src │ │ └── net │ │ └── println │ │ └── kt02 │ │ └── Main.kt └── Kt01 │ └── src │ └── net │ └── println │ └── kt01 │ └── Main.kt ├── .gitignore ├── arts ├── Kotlin.jpg ├── e_group.png ├── Kotlin-logo.png ├── contributes.jpg └── kotlin扫码关注.png ├── script ├── Kt01 简介.pptx ├── Kt12 解析Json数据.key ├── Kt12 面向对象的几个概念.key └── Kt14 Kotlin 与 Java 共存(一).potx └── articles ├── 2016.12.26.jpg ├── 2017.1.2 ├── try.gif ├── 17.1.2.jpg ├── args.gif ├── 17.1.2b.jpg ├── 像写文章一样使用 Kotlin.md └── Kotlin 1.0.6.md ├── 2017.1.9 ├── lt2.png ├── lt3.png ├── lt4.png ├── lt5.png ├── lt6.png ├── lt8.png ├── lt9.png ├── tab.gif ├── action.gif ├── array.jpg ├── enter.gif ├── lt10.png ├── lt11.png ├── lt12.png ├── lt13.png ├── lt14.png ├── lt15.png ├── main.gif ├── posix.png ├── search.png ├── comment.gif ├── comment2.gif ├── comment3.gif ├── intellij.jpg ├── newline.gif ├── newline2.gif ├── newline3.gif ├── search2.png ├── swap_fun.gif ├── findaction.png ├── iter_smart.gif ├── iter_stupid.gif ├── multiline.gif ├── multiline2.gif ├── swap_action.png ├── swap_smart.gif ├── swap_stupid.gif ├── livetemplate.png ├── multiline_action.png ├── newline_action.png └── 高效地使用你的 IntelliJ.md ├── 2017.1.16 └── cover.jpg ├── 2017.1.21 ├── check.png ├── houzi.png ├── choose.png ├── 1.1-Beta-Banner-2-01.png └── 喜大普奔!Kotlin 1.1 Beta 降临~.md ├── 2017.1.23 ├── cover.jpg ├── linear.png └── relative.png ├── 2017.1.30 ├── cr0.png ├── cr1.png ├── cr2.png ├── mdhere.gif ├── coroutine_cover.jpg ├── coroutine_lua.png ├── 如何优雅的在微信公众号中编辑代码.jpg └── 勘误:15 Kotlin 与 Java 共存 (2) .md ├── 2017.2.20 ├── cover.jpg ├── right.jpg ├── road.JPG ├── 11RC-01.png ├── growup.png ├── wangzhe.jpg ├── zhiyin.jpg ├── embarassed.png ├── high_order_fun.jpg └── Kotlin 1.1:我们都路上.md ├── 2017.3.20 ├── cover.jpg └── wechat_group.jpg ├── 2017.3.27 └── cover.jpg ├── 2017.2.13 └── lambda.jpg ├── 2017.3.13 ├── 快速上手 Kotlin 11招.jpg └── Kotlin Script 介绍.jpg ├── 2017.2.6 ├── Kotlin 1.1 Beta 2 发布~.jpg └── Kotlin 1.1 Beta 2 发布~.md ├── 2017.3.4 └── Kotlin11blogbanner1.jpg └── 2016.12.26 Kotlin 如何优雅的实现『多继承』.md /code/RealmIssue/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /code/RealmIssue/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /code/Kt14/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':Kt14', ':kt14internal' -------------------------------------------------------------------------------- /code/Kt03/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt03' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt04/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt04' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt05/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt05' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt06/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt06' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt08/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt08' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt10/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt10' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt11/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt11' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt12/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt12' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt13/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt13' 2 | 3 | -------------------------------------------------------------------------------- /code/Kt15/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Kt15' 2 | 3 | -------------------------------------------------------------------------------- /code/kt07/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kt07' 2 | 3 | -------------------------------------------------------------------------------- /code/MyBatisIssue/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MyBatisIssue' 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | videos 2 | build 3 | .gradle 4 | *.iml 5 | .idea 6 | out 7 | raw 8 | cache 9 | beta -------------------------------------------------------------------------------- /arts/Kotlin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/arts/Kotlin.jpg -------------------------------------------------------------------------------- /arts/e_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/arts/e_group.png -------------------------------------------------------------------------------- /arts/Kotlin-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/arts/Kotlin-logo.png -------------------------------------------------------------------------------- /arts/contributes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/arts/contributes.jpg -------------------------------------------------------------------------------- /arts/kotlin扫码关注.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/arts/kotlin扫码关注.png -------------------------------------------------------------------------------- /script/Kt01 简介.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/script/Kt01 简介.pptx -------------------------------------------------------------------------------- /articles/2016.12.26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2016.12.26.jpg -------------------------------------------------------------------------------- /articles/2017.1.2/try.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.2/try.gif -------------------------------------------------------------------------------- /articles/2017.1.9/lt2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt2.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt3.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt4.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt5.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt6.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt8.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt9.png -------------------------------------------------------------------------------- /articles/2017.1.9/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/tab.gif -------------------------------------------------------------------------------- /script/Kt12 解析Json数据.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/script/Kt12 解析Json数据.key -------------------------------------------------------------------------------- /script/Kt12 面向对象的几个概念.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/script/Kt12 面向对象的几个概念.key -------------------------------------------------------------------------------- /articles/2017.1.16/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.16/cover.jpg -------------------------------------------------------------------------------- /articles/2017.1.2/17.1.2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.2/17.1.2.jpg -------------------------------------------------------------------------------- /articles/2017.1.2/args.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.2/args.gif -------------------------------------------------------------------------------- /articles/2017.1.21/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.21/check.png -------------------------------------------------------------------------------- /articles/2017.1.21/houzi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.21/houzi.png -------------------------------------------------------------------------------- /articles/2017.1.23/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.23/cover.jpg -------------------------------------------------------------------------------- /articles/2017.1.30/cr0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/cr0.png -------------------------------------------------------------------------------- /articles/2017.1.30/cr1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/cr1.png -------------------------------------------------------------------------------- /articles/2017.1.30/cr2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/cr2.png -------------------------------------------------------------------------------- /articles/2017.1.9/action.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/action.gif -------------------------------------------------------------------------------- /articles/2017.1.9/array.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/array.jpg -------------------------------------------------------------------------------- /articles/2017.1.9/enter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/enter.gif -------------------------------------------------------------------------------- /articles/2017.1.9/lt10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt10.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt11.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt12.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt13.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt14.png -------------------------------------------------------------------------------- /articles/2017.1.9/lt15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/lt15.png -------------------------------------------------------------------------------- /articles/2017.1.9/main.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/main.gif -------------------------------------------------------------------------------- /articles/2017.1.9/posix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/posix.png -------------------------------------------------------------------------------- /articles/2017.1.9/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/search.png -------------------------------------------------------------------------------- /articles/2017.2.20/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/cover.jpg -------------------------------------------------------------------------------- /articles/2017.2.20/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/right.jpg -------------------------------------------------------------------------------- /articles/2017.2.20/road.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/road.JPG -------------------------------------------------------------------------------- /articles/2017.3.20/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.3.20/cover.jpg -------------------------------------------------------------------------------- /articles/2017.3.27/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.3.27/cover.jpg -------------------------------------------------------------------------------- /articles/2017.1.2/17.1.2b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.2/17.1.2b.jpg -------------------------------------------------------------------------------- /articles/2017.1.21/choose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.21/choose.png -------------------------------------------------------------------------------- /articles/2017.1.23/linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.23/linear.png -------------------------------------------------------------------------------- /articles/2017.1.30/mdhere.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/mdhere.gif -------------------------------------------------------------------------------- /articles/2017.1.9/comment.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/comment.gif -------------------------------------------------------------------------------- /articles/2017.1.9/comment2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/comment2.gif -------------------------------------------------------------------------------- /articles/2017.1.9/comment3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/comment3.gif -------------------------------------------------------------------------------- /articles/2017.1.9/intellij.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/intellij.jpg -------------------------------------------------------------------------------- /articles/2017.1.9/newline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/newline.gif -------------------------------------------------------------------------------- /articles/2017.1.9/newline2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/newline2.gif -------------------------------------------------------------------------------- /articles/2017.1.9/newline3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/newline3.gif -------------------------------------------------------------------------------- /articles/2017.1.9/search2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/search2.png -------------------------------------------------------------------------------- /articles/2017.1.9/swap_fun.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/swap_fun.gif -------------------------------------------------------------------------------- /articles/2017.2.13/lambda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.13/lambda.jpg -------------------------------------------------------------------------------- /articles/2017.2.20/11RC-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/11RC-01.png -------------------------------------------------------------------------------- /articles/2017.2.20/growup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/growup.png -------------------------------------------------------------------------------- /articles/2017.2.20/wangzhe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/wangzhe.jpg -------------------------------------------------------------------------------- /articles/2017.2.20/zhiyin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/zhiyin.jpg -------------------------------------------------------------------------------- /articles/2017.1.23/relative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.23/relative.png -------------------------------------------------------------------------------- /articles/2017.1.9/findaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/findaction.png -------------------------------------------------------------------------------- /articles/2017.1.9/iter_smart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/iter_smart.gif -------------------------------------------------------------------------------- /articles/2017.1.9/iter_stupid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/iter_stupid.gif -------------------------------------------------------------------------------- /articles/2017.1.9/multiline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/multiline.gif -------------------------------------------------------------------------------- /articles/2017.1.9/multiline2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/multiline2.gif -------------------------------------------------------------------------------- /articles/2017.1.9/swap_action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/swap_action.png -------------------------------------------------------------------------------- /articles/2017.1.9/swap_smart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/swap_smart.gif -------------------------------------------------------------------------------- /articles/2017.1.9/swap_stupid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/swap_stupid.gif -------------------------------------------------------------------------------- /articles/2017.2.20/embarassed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/embarassed.png -------------------------------------------------------------------------------- /articles/2017.1.9/livetemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/livetemplate.png -------------------------------------------------------------------------------- /articles/2017.3.20/wechat_group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.3.20/wechat_group.jpg -------------------------------------------------------------------------------- /code/Kt06/src/main/java/net/println/kt06/EnumInJava.java: -------------------------------------------------------------------------------- 1 | package net.println.kt06; 2 | 3 | public enum EnumInJava { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /code/Kt12/result_singer_field_loss.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 0, 3 | "message": "ok", 4 | "content": { 5 | "id": 1 6 | } 7 | } -------------------------------------------------------------------------------- /articles/2017.1.30/coroutine_cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/coroutine_cover.jpg -------------------------------------------------------------------------------- /articles/2017.1.30/coroutine_lua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/coroutine_lua.png -------------------------------------------------------------------------------- /articles/2017.1.9/multiline_action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/multiline_action.png -------------------------------------------------------------------------------- /articles/2017.1.9/newline_action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.9/newline_action.png -------------------------------------------------------------------------------- /articles/2017.2.20/high_order_fun.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.20/high_order_fun.jpg -------------------------------------------------------------------------------- /articles/2017.3.13/快速上手 Kotlin 11招.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.3.13/快速上手 Kotlin 11招.jpg -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/java/net/println/kotlin/realm/PoKo.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.realm 2 | 3 | annotation class PoKo 4 | -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RealmDemo 3 | 4 | -------------------------------------------------------------------------------- /script/Kt14 Kotlin 与 Java 共存(一).potx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/script/Kt14 Kotlin 与 Java 共存(一).potx -------------------------------------------------------------------------------- /articles/2017.1.30/如何优雅的在微信公众号中编辑代码.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.30/如何优雅的在微信公众号中编辑代码.jpg -------------------------------------------------------------------------------- /articles/2017.3.13/Kotlin Script 介绍.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.3.13/Kotlin Script 介绍.jpg -------------------------------------------------------------------------------- /articles/2017.1.21/1.1-Beta-Banner-2-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.1.21/1.1-Beta-Banner-2-01.png -------------------------------------------------------------------------------- /articles/2017.2.6/Kotlin 1.1 Beta 2 发布~.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.2.6/Kotlin 1.1 Beta 2 发布~.jpg -------------------------------------------------------------------------------- /articles/2017.3.4/Kotlin11blogbanner1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/articles/2017.3.4/Kotlin11blogbanner1.jpg -------------------------------------------------------------------------------- /code/Kt03/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt03/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt04/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt04/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt05/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt05/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt06/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt06/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt08/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt08/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt09/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt09/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt10/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt10/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt11/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt11/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt12/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt12/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt13/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt13/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt14/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt14/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/Kt15/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/Kt15/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/kt07/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/kt07/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/RealmIssue/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/MyBatisIssue/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/MyBatisIssue/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /code/MyBatisIssue/libs/mysql-connector-java-5.1.40-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/MyBatisIssue/libs/mysql-connector-java-5.1.40-bin.jar -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/resources/net/println/kotlin/mybatis/db.properties: -------------------------------------------------------------------------------- 1 | driver=com.mysql.jdbc.Driver 2 | url=jdbc:mysql://localhost:3306/User 3 | username=root 4 | password= -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /code/Kt11/src/main/kotlin/net/println/kt11/State.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt11 2 | 3 | /** 4 | * Created by benny on 11/27/16. 5 | */ 6 | enum class State { 7 | IDLE, PAUSED, PLAYING 8 | } -------------------------------------------------------------------------------- /code/RealmIssue/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /code/Kt03/src/main/kotlin/net/println/kt03/User.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt03 2 | 3 | /** 4 | * Created by benny on 10/11/16. 5 | */ 6 | data class User(val id : Int, val name : String) { 7 | 8 | } -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /code/Kt10/src/main/kotlin/net/println/kt10/kotlin/PlainOldSingleton.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt10.kotlin 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | object PlainOldSingleton { 7 | 8 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/Person.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | data class Person(var name:String, @JvmField var age: Int) -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enbandari/Kotlin-Tutorials/HEAD/code/RealmIssue/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /code/Kt04/src/main/java/net/println/kt04/ConsoleParam.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt04 2 | 3 | /** 4 | * Created by benny on 10/14/16. 5 | */ 6 | fun main(args: Array): Unit{ 7 | args.map(::println) 8 | } -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/kotlin/net/println/kotlin/mybatis/annotations/PoKo.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.mybatis.annotations 2 | 3 | /** 4 | * Created by benny on 3/25/17. 5 | */ 6 | annotation class PoKo -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/ExtensionMethod.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun String.notEmpty(): Boolean{ 7 | return this != "" 8 | } -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/config/Settings.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.config 2 | 3 | /** 4 | * Created by benny on 12/11/16. 5 | */ 6 | object Settings { 7 | 8 | const val DEBUG = true 9 | 10 | } -------------------------------------------------------------------------------- /code/Kt12/src/main/kotlin/net/println/kt12/GsonExt.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt12 2 | 3 | import com.google.gson.Gson 4 | 5 | inline fun Gson.fromJson(json: String): T{ 6 | return fromJson(json, T::class.java) 7 | } -------------------------------------------------------------------------------- /code/Kt12/src/main/java/net/println/kt12/Main.java: -------------------------------------------------------------------------------- 1 | package net.println.kt12; 2 | 3 | /** 4 | * Created by benny on 12/4/16. 5 | */ 6 | public class Main { 7 | public static void main(String... args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/Singleton.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | object Singleton { 7 | fun printlnHello(){ 8 | println("Hello") 9 | } 10 | } -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/resources/net/println/kotlin/mybatis/userinfo.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE userinfo 2 | ( 3 | id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, 4 | username VARCHAR(45), 5 | age INT(11), 6 | passwd VARCHAR(45) 7 | ); -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/Package.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun printlnHello(){ 7 | println("Hello") 8 | } 9 | 10 | fun main(args: Array) { 11 | 12 | } -------------------------------------------------------------------------------- /code/Kt15/src/main/java/net/println/kt15/NullSafetyJava.java: -------------------------------------------------------------------------------- 1 | package net.println.kt15; 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | public class NullSafetyJava { 7 | public String getData(){ 8 | return null; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/kotlin/net/println/kotlin/mybatis/Main.java: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.mybatis; 2 | 3 | /** 4 | * Created by benny on 3/26/17. 5 | */ 6 | public class Main { 7 | public static void main(String... args) { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/CallInternalClass.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun main(args: Array) { 7 | val internalClass = InternalClass() 8 | internalClass.printlnHello() 9 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/InternalClass.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | internal class InternalClass{ 7 | internal fun printlnHello(){ 8 | println("Hello") 9 | } 10 | } -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/java/net/println/kotlin/realm/User.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.realm 2 | 3 | import io.realm.RealmObject 4 | import io.realm.annotations.PrimaryKey 5 | 6 | @PoKo 7 | data class User(@PrimaryKey var id: Int, var name: String) : RealmObject() -------------------------------------------------------------------------------- /code/Kt12/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Program 4 | { 5 | public static void Main(String[] args) 6 | { 7 | testGeneric(); 8 | } 9 | 10 | public static void testGeneric(){ 11 | Console.WriteLine(typeof(T)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /code/Kt15/src/main/kotlin/net/println/kt15/ConcurrentRelated.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt15 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | @Volatile var count: Int = 0 7 | 8 | fun count(){ 9 | synchronized(count){ 10 | count++ 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /code/Kt14/kt14internal/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | 4 | dependencies { 5 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 6 | compile project(":Kt14") 7 | testCompile group: 'junit', name: 'junit', version: '4.11' 8 | } 9 | -------------------------------------------------------------------------------- /code/Kt15/src/main/kotlin/net/println/kt15/AccessDataClass.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt15 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun main(args: Array) { 7 | val dataClass = DataClass() 8 | dataClass.id = 0 9 | println(dataClass.id) 10 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | 4 | sourceCompatibility = 1.5 5 | 6 | dependencies { 7 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 8 | testCompile group: 'junit', name: 'junit', version: '4.11' 9 | } 10 | -------------------------------------------------------------------------------- /code/Kt03/src/main/java/net/println/kt03/Hello.java: -------------------------------------------------------------------------------- 1 | package net.println.kt03; 2 | 3 | /** 4 | * Created by benny on 10/12/16. 5 | */ 6 | public class Hello { 7 | public static void main(String... args) { 8 | int a = 021; 9 | System.out.println(a); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /code/Kt08/src/main/java/net/println/kt08/User.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt08 2 | 3 | /** 4 | * Created by benny on 11/1/16. 5 | */ 6 | data class User(val login: String, val id: Long, val avatar_url: String){ 7 | override fun toString(): String { 8 | return login 9 | } 10 | } -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/User.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt08 2 | 3 | /** 4 | * Created by benny on 11/1/16. 5 | */ 6 | data class User(val login: String, val id: Long, val avatar_url: String){ 7 | override fun toString(): String { 8 | return login 9 | } 10 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/java/net/println/kt14/CallPackageMethod.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14; 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | public class CallPackageMethod{ 7 | public static void main(String... args) { 8 | PackageKt.printlnHello(); 9 | } 10 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/kotlin/net/println/kt14/Overloads.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14 2 | 3 | /** 4 | * Created by benny on 12/18/16. 5 | */ 6 | class Overloads { 7 | @JvmOverloads 8 | fun overloaded(a: Int, b: Int = 0, c: Int = 1){ 9 | println("$a, $b, $c") 10 | } 11 | } -------------------------------------------------------------------------------- /code/Kt03/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 11 23:18:44 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip 7 | -------------------------------------------------------------------------------- /code/Kt04/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 12 23:22:16 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt05/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Oct 14 22:31:22 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt06/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Oct 15 23:36:13 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt08/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 27 21:43:09 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt09/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Nov 04 08:40:27 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt10/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Nov 12 22:19:31 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt11/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Nov 20 13:30:26 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt12/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 28 22:47:53 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt13/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 28 22:47:53 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt14/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 17 10:32:19 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/Kt15/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 17 21:40:38 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /code/kt07/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Oct 24 13:46:24 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip 7 | -------------------------------------------------------------------------------- /code/Kt02/src/net/println/kt02/Main.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt02 2 | 3 | /** 4 | * Created by benny on 10/11/16. 5 | */ 6 | 7 | fun main(args : Array){ 8 | println("Hello World!!!") 9 | println(Main(0, "bennyhuo")) 10 | } 11 | 12 | data class Main(val id : Int, val name: String) -------------------------------------------------------------------------------- /code/Kt03/src/main/java/net/println/kt03/HelloJava.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt03 2 | 3 | /** 4 | * Created by benny on 10/11/16. 5 | */ 6 | object HelloJava { 7 | @JvmStatic fun main(args: Array) { 8 | val user = User(0, "bennyhuo") 9 | println(user) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/java/net/println/kt14/AccessToObject.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14; 2 | 3 | /** 4 | * Created by benny on 12/18/16. 5 | */ 6 | public class AccessToObject { 7 | public static void main(String... args) { 8 | Singleton.INSTANCE.printlnHello(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /code/MyBatisIssue/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Mar 25 09:41:11 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip 7 | -------------------------------------------------------------------------------- /code/RealmIssue/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 29 09:18:08 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /code/Kt14/kt14internal/src/main/kotlin/net/println/kt14internal/CallInternalClassKt.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt14internal 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun main(args: Array) { 7 | // val internalClass = InternalClass() 8 | // internalClass.printHello() 9 | } 10 | -------------------------------------------------------------------------------- /code/Kt12/singer.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1, 3 | "name": "Unknown", 4 | "songs": [ 5 | { 6 | "id": 0, 7 | "name": "Rada" 8 | }, 9 | { 10 | "id": 1, 11 | "name": "Olympic Dream" 12 | }, 13 | { 14 | "id": 2, 15 | "name": "The Escapist" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/kotlin/net/println/kotlin/mybatis/UserMapper.java: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.mybatis; 2 | 3 | /** 4 | * Created by benny on 3/25/17. 5 | */ 6 | //@Mapper 7 | public interface UserMapper { 8 | // @Select("SELECT * FROM userinfo WHERE id = #{id}") 9 | User selectUser(int id); 10 | } -------------------------------------------------------------------------------- /code/Kt12/result_songs.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 0, 3 | "message": "ok", 4 | "content": [ 5 | { 6 | "id": 0, 7 | "name": "Rada" 8 | }, 9 | { 10 | "id": 1, 11 | "name": "Olympic Dream" 12 | }, 13 | { 14 | "id": 2, 15 | "name": "The Escapist" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/java/net/println/kt14/CallExtenstionMethod.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14; 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | public class CallExtenstionMethod { 7 | public static void main(String... args) { 8 | System.out.println(ExtensionMethodKt.notEmpty("Hello")); 9 | } 10 | } -------------------------------------------------------------------------------- /code/Kt04/src/main/java/net/println/kt04/ConsoleParamInJava.java: -------------------------------------------------------------------------------- 1 | package net.println.kt04; 2 | 3 | /** 4 | * Created by benny on 10/14/16. 5 | */ 6 | public class ConsoleParamInJava { 7 | public static void main(String... args) { 8 | for (String arg : args) { 9 | System.out.println(arg); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/Kt05/src/main/java/net/println/kt05/ConsoleParam2.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt05 2 | 3 | /** 4 | * a_b_c d_e f_g_h_j 5 | * a b c d e f g h j 6 | * Created by benny on 10/14/16. 7 | */ 8 | fun main(vararg args: String) { 9 | args.flatMap { 10 | it.split("_") 11 | }.map { 12 | print("$it ${it.length}") 13 | } 14 | } -------------------------------------------------------------------------------- /code/Kt15/src/main/java/net/println/kt15/DataClass.java: -------------------------------------------------------------------------------- 1 | package net.println.kt15; 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | public class DataClass { 7 | private int id; 8 | 9 | public int getId() { 10 | return id; 11 | } 12 | 13 | public void setId(int id) { 14 | this.id = id; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /code/Kt15/src/main/kotlin/net/println/kt15/NullSafety.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt15 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun main(args: Array) { 7 | val nullSafetyJava = NullSafetyJava() 8 | val data: String = nullSafetyJava.data 9 | val dataCanBeNull: String? = nullSafetyJava.data 10 | println(data) 11 | } -------------------------------------------------------------------------------- /code/Kt12/src/main/kotlin/net/println/kt12/Data.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt12 2 | 3 | /** 4 | * Created by benny on 12/1/16. 5 | */ 6 | data class BaseResult(val code: Int, val message: String, val content: Content) 7 | 8 | data class Song(val id: Long, val name: String) 9 | 10 | data class Singer(val id: Long, val name: String, val songs: List) 11 | -------------------------------------------------------------------------------- /code/Kt03/src/main/java/net/println/kt03/HelloKotlin.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt03 2 | 3 | /** 4 | * Created by benny on 10/11/16. 5 | */ 6 | fun main(args: Array){ 7 | val user = User(0, "bennyhuo") 8 | println(user) 9 | 10 | HelloKotlin::class.constructors.map(::println) 11 | } 12 | 13 | class HelloKotlin{ 14 | fun hello(){ 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/module/GsonModule.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.module 2 | 3 | import com.google.gson.Gson 4 | import dagger.Module 5 | import dagger.Provides 6 | import javax.inject.Singleton 7 | 8 | /** 9 | * Created by benny on 12/11/16. 10 | */ 11 | @Module 12 | class GsonModule { 13 | 14 | @Singleton @Provides fun gson(): Gson = Gson() 15 | } -------------------------------------------------------------------------------- /code/Kt01/src/net/println/kt01/Main.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt01 2 | 3 | /** 4 | * Created by benny on 10/11/16. 5 | */ 6 | fun main(args: Array){ 7 | println("Hello World!!") 8 | println(Main("Bennyhuo", 0)) 9 | } 10 | 11 | class Main(val title: String, val id: Int){ 12 | override fun toString(): String { 13 | return "$id - $title" 14 | } 15 | } -------------------------------------------------------------------------------- /code/Kt11/src/main/kotlin/net/println/kt11/Main.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt11 2 | 3 | /** 4 | * Created by benny on 11/27/16. 5 | */ 6 | fun main(args: Array) { 7 | val player: Player = Player() 8 | player.play("http://ws.stream.qqmusic.qq.com/C2000012Ppbd3hjGOK.m4a") 9 | player.pause() 10 | player.resume() 11 | player.seekTo(30000) 12 | player.stop() 13 | } -------------------------------------------------------------------------------- /code/Kt12/src/main/kotlin/net/println/kt12/Main.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt12 2 | 3 | import java.io.File 4 | 5 | /** 6 | * Created by benny on 12/1/16. 7 | */ 8 | fun main(args: Array) { 9 | val json = File("result_singer_field_loss.json").readText() 10 | val result : BaseResult = ApiFactory.api.getSingerFromJson(json) 11 | println(result.content.name.isEmpty()) 12 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/java/net/println/kt14/CallInternalClass.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14; 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | 7 | public class CallInternalClass{ 8 | public static void main(String... args) { 9 | InternalClass internalClass = new InternalClass(); 10 | internalClass.printlnHello$production_sources_for_module_Kt14_Kt14_main(); 11 | } 12 | } -------------------------------------------------------------------------------- /code/Kt14/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.5-2' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenCentral() 18 | } 19 | } -------------------------------------------------------------------------------- /code/Kt12/result_singer.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 0, 3 | "message": "ok", 4 | "content": { 5 | "id": 1, 6 | "name": "Unknown", 7 | "songs": [ 8 | { 9 | "id": 0, 10 | "name": "Rada" 11 | }, 12 | { 13 | "id": 1, 14 | "name": "Olympic Dream" 15 | }, 16 | { 17 | "id": 2, 18 | "name": "The Escapist" 19 | } 20 | ] 21 | } 22 | } -------------------------------------------------------------------------------- /code/Kt11/src/main/kotlin/net/println/kt11/PlayerCmd.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt11 2 | 3 | /** 4 | * Created by benny on 11/27/16. 5 | */ 6 | sealed class PlayerCmd { 7 | class Play(val url: String, val position: Long = 0): PlayerCmd() 8 | 9 | class Seek(val position: Long): PlayerCmd() 10 | 11 | object Pause: PlayerCmd() 12 | 13 | object Resume: PlayerCmd() 14 | 15 | object Stop: PlayerCmd() 16 | } -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/java/net/println/kt14/AccessToOverloads.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14; 2 | 3 | /** 4 | * Created by benny on 12/18/16. 5 | */ 6 | public class AccessToOverloads { 7 | public static void main(String... args) { 8 | Overloads overloads = new Overloads(); 9 | overloads.overloaded(1, 2, 3); 10 | overloads.overloaded(1); 11 | overloads.overloaded(1,3); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/kotlin/net/println/kotlin/mybatis/User.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.mybatis 2 | 3 | import net.println.kotlin.mybatis.annotations.PoKo 4 | 5 | /** 6 | * Created by benny on 3/25/17. 7 | */ 8 | @PoKo 9 | data class User (var id: Int, var username: String = "", var age: Int, var passwd: String = "") 10 | 11 | fun main(args: Array) { 12 | //println(User::class.java.newInstance()) 13 | } -------------------------------------------------------------------------------- /code/Kt10/src/main/kotlin/net/println/kt10/kotlin/LazyThreadSafeStaticInnerObject.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt10.kotlin 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | class LazyThreadSafeStaticInnerObject private constructor(){ 7 | companion object{ 8 | fun getInstance() = Holder.instance 9 | } 10 | 11 | private object Holder{ 12 | val instance = LazyThreadSafeStaticInnerObject() 13 | } 14 | } -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/RESTFulComponent.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13 2 | 3 | import dagger.Component 4 | import net.println.kt13.module.RetrofitModule 5 | import retrofit2.Retrofit 6 | import javax.inject.Singleton 7 | 8 | /** 9 | * Created by benny on 12/11/16. 10 | */ 11 | @Singleton 12 | @Component(modules = arrayOf(RetrofitModule::class)) 13 | interface RESTFulComponent { 14 | fun retrofit(): Retrofit 15 | } -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/resources/net/println/kotlin/mybatis/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /code/Kt14/kt14internal/src/main/java/net/println/kt14internal/CallInternalClass.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14internal; 2 | 3 | import net.println.kt14.InternalClass; 4 | 5 | /** 6 | * Created by benny on 12/17/16. 7 | */ 8 | public class CallInternalClass { 9 | public static void main(String... args) { 10 | InternalClass internalClass = new InternalClass(); 11 | internalClass.printlnHello$production_sources_for_module_Kt14_Kt14_main(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /code/Kt10/src/main/java/net/println/kt10/java/PlainOldSingleton.java: -------------------------------------------------------------------------------- 1 | package net.println.kt10.java; 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | public class PlainOldSingleton { 7 | private static PlainOldSingleton INSTANCE = new PlainOldSingleton(); 8 | 9 | private PlainOldSingleton(){ 10 | System.out.println("PlainOldSingleton"); 11 | } 12 | 13 | public static PlainOldSingleton getInstance(){ 14 | return INSTANCE; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/module/RxAdapterModule.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.module 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import retrofit2.CallAdapter 6 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory 7 | import javax.inject.Singleton 8 | 9 | /** 10 | * Created by benny on 12/11/16. 11 | */ 12 | @Module 13 | class RxAdapterModule { 14 | @Singleton @Provides fun adapter(): CallAdapter.Factory = RxJavaCallAdapterFactory.create() 15 | } -------------------------------------------------------------------------------- /code/kt07/src/main/Resources/input: -------------------------------------------------------------------------------- 1 | This reference is designed for you to easily learn Kotlin in a matter of hours. Start with the basic syntax, then proceed to more advanced topics. While reading, you can try out the examples in the online IDE. 2 | 3 | Once you get an idea of what Kotlin looks like, try yourself in solving some Kotlin Koans - interactive programming exercises. If you are not sure how to solve a Koan, or you're looking for a more elegant solution, check out Kotlin idioms. 4 | 5 | -------------------------------------------------------------------------------- /code/Kt10/src/main/java/net/println/kt10/java/LazyNotThreadSafe.java: -------------------------------------------------------------------------------- 1 | package net.println.kt10.java; 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | public class LazyNotThreadSafe { 7 | private static LazyNotThreadSafe INSTANCE; 8 | 9 | private LazyNotThreadSafe(){} 10 | 11 | public static LazyNotThreadSafe getInstance(){ 12 | if(INSTANCE == null){ 13 | INSTANCE = new LazyNotThreadSafe(); 14 | } 15 | return INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code/Kt14/Kt14/src/main/java/net/println/kt14/PersonMain.java: -------------------------------------------------------------------------------- 1 | package net.println.kt14; 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | public class PersonMain { 7 | public static void main(String... args) { 8 | Person person = new Person("benny", 27); 9 | System.out.println(person.getName() + " is " + person.age); 10 | person.setName("andy"); 11 | person.age = 26; 12 | System.out.println(person.getName() + " is " + person.age); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /code/Kt05/src/main/java/net/println/kt05/ConsoleParamInJava.java: -------------------------------------------------------------------------------- 1 | package net.println.kt05; 2 | 3 | /** 4 | * Created by benny on 10/14/16. 5 | */ 6 | public class ConsoleParamInJava { 7 | public static void main(String... args) { 8 | for (String arg: args){ 9 | String[] splits = arg.split("_"); 10 | for (String split : splits) { 11 | System.out.print(split); 12 | System.out.print(" "); 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /code/Kt15/src/main/java/net/println/kt15/NullSafetyAbsClass.java: -------------------------------------------------------------------------------- 1 | package net.println.kt15; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by benny on 12/17/16. 10 | */ 11 | public abstract class NullSafetyAbsClass { 12 | public abstract String formatDate(Date date); 13 | 14 | public @NotNull String formatTime(@NotNull Date date){ 15 | return new SimpleDateFormat("HH:mm:ss").format(date); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/module/OkHttpClientModule.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.module 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import okhttp3.Cache 6 | import okhttp3.OkHttpClient 7 | import javax.inject.Singleton 8 | 9 | /** 10 | * Created by benny on 12/11/16. 11 | */ 12 | @Module(includes = arrayOf(CacheModule::class)) 13 | class OkHttpClientModule { 14 | @Singleton @Provides fun okHttpClient(cache: Cache): OkHttpClient 15 | = OkHttpClient.Builder().cache(cache).build() 16 | } -------------------------------------------------------------------------------- /code/Kt15/src/main/kotlin/net/println/kt15/NullSafetySubClass.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt15 2 | 3 | import java.util.* 4 | 5 | /** 6 | * Created by benny on 12/17/16. 7 | */ 8 | class NullSafetySubClass : NullSafetyAbsClass(){ 9 | override fun formatDate(date: Date): String { 10 | return date.toString() 11 | } 12 | } 13 | 14 | fun main(args: Array) { 15 | val nullSafetySubClass = NullSafetySubClass() 16 | println(nullSafetySubClass.formatDate(Date())) 17 | println(nullSafetySubClass.formatTime(Date())) 18 | } -------------------------------------------------------------------------------- /code/kt07/src/main/java/net/println/kt07/Lambda.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt07 2 | 3 | import rx.Observable 4 | import java.io.File 5 | import java.util.concurrent.Executors 6 | 7 | fun main(args: Array) { 8 | val text = File(ClassLoader.getSystemResource("input").path).readText() 9 | Observable.from(text.toCharArray().asIterable()).filter { !it.isWhitespace() }.groupBy { it }.subscribe { 10 | o -> o.count().subscribe{ 11 | println("${o.key} -> $it") 12 | } 13 | } 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /code/Kt10/src/main/kotlin/net/println/kt10/kotlin/LazyThreadSafeSynchronized.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt10.kotlin 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | class LazyThreadSafeSynchronized private constructor() { 7 | companion object { 8 | private var instance: LazyThreadSafeSynchronized? = null 9 | 10 | @Synchronized 11 | fun get(): LazyThreadSafeSynchronized{ 12 | if(instance == null) instance = LazyThreadSafeSynchronized() 13 | return instance!! 14 | } 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/module/CacheModule.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.module 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import okhttp3.Cache 6 | import java.io.File 7 | import javax.inject.Singleton 8 | 9 | /** 10 | * Created by benny on 12/11/16. 11 | */ 12 | @Module 13 | class CacheModule { 14 | companion object{ 15 | const val CACHE_DIR = "./cache" 16 | const val CACHE_SIZE = 10 * 1024 * 1024L 17 | } 18 | 19 | @Singleton @Provides fun cache(): Cache = Cache(File(CACHE_DIR), CACHE_SIZE) 20 | } -------------------------------------------------------------------------------- /code/Kt10/src/main/java/net/println/kt10/java/LazyThreadSafeStaticInnerClass.java: -------------------------------------------------------------------------------- 1 | package net.println.kt10.java; 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | public class LazyThreadSafeStaticInnerClass { 7 | 8 | private static class Holder{ 9 | private static LazyThreadSafeStaticInnerClass INSTANCE = new LazyThreadSafeStaticInnerClass(); 10 | } 11 | 12 | private LazyThreadSafeStaticInnerClass(){} 13 | 14 | public static LazyThreadSafeStaticInnerClass getInstance(){ 15 | return Holder.INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code/Kt10/src/main/java/net/println/kt10/java/LazyThreadSafeSynchronized.java: -------------------------------------------------------------------------------- 1 | package net.println.kt10.java; 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | public class LazyThreadSafeSynchronized { 7 | private static LazyThreadSafeSynchronized INSTANCE; 8 | 9 | private LazyThreadSafeSynchronized(){} 10 | 11 | public static synchronized LazyThreadSafeSynchronized getInstance(){ 12 | if(INSTANCE == null){ 13 | INSTANCE = new LazyThreadSafeSynchronized(); 14 | } 15 | return INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/module/GsonConverterModule.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.module 2 | 3 | import com.google.gson.Gson 4 | import dagger.Module 5 | import dagger.Provides 6 | import retrofit2.Converter 7 | import retrofit2.converter.gson.GsonConverterFactory 8 | import javax.inject.Singleton 9 | 10 | /** 11 | * Created by benny on 12/11/16. 12 | */ 13 | @Module(includes = arrayOf(GsonModule::class)) 14 | class GsonConverterModule { 15 | @Singleton @Provides fun converter(gson: Gson): Converter.Factory = GsonConverterFactory.create(gson) 16 | } -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/java/net/println/kotlin/realm/App.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.realm 2 | 3 | import android.app.Application 4 | 5 | import io.realm.Realm 6 | import io.realm.RealmConfiguration 7 | 8 | class App : Application() { 9 | override fun onCreate() { 10 | super.onCreate() 11 | Realm.init(this) 12 | Realm.setDefaultConfiguration( 13 | RealmConfiguration.Builder() 14 | .deleteRealmIfMigrationNeeded() 15 | .schemaVersion(1) 16 | .build()) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /code/Kt15/src/main/kotlin/net/println/kt15/GenericsInKt.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt15 2 | 3 | import java.util.* 4 | 5 | /** 6 | * Created by benny on 12/17/16. 7 | */ 8 | //Kotlin 无法写出这样的代码 9 | //abstract class View

>>{ 10 | // protected abstract val presenter: P 11 | //} 12 | // 13 | //abstract class Presenter>>{ 14 | // protected abstract val view: V 15 | //} 16 | 17 | fun main(args: Array) { 18 | val list = ArrayList() 19 | list.add("Hello") 20 | list.add(0) 21 | list.map(::println) 22 | } -------------------------------------------------------------------------------- /code/Kt11/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | jcenter() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | testCompile group: 'junit', name: 'junit', version: '4.11' 27 | } 28 | -------------------------------------------------------------------------------- /code/Kt05/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | testCompile group: 'junit', name: 'junit', version: '4.11' 27 | } 28 | -------------------------------------------------------------------------------- /code/Kt06/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | testCompile group: 'junit', name: 'junit', version: '4.11' 27 | } 28 | -------------------------------------------------------------------------------- /code/Kt10/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | testCompile group: 'junit', name: 'junit', version: '4.11' 27 | } 28 | -------------------------------------------------------------------------------- /code/Kt13/src/main/kotlin/net/println/kt13/module/BaseUrlModule.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt13.module 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | import net.println.kt13.config.Settings 6 | import javax.inject.Singleton 7 | 8 | /** 9 | * Created by benny on 12/11/16. 10 | */ 11 | @Module 12 | class BaseUrlModule { 13 | companion object{ 14 | //测试环境 15 | const val DEBUG_URL = "https://api.github.com" 16 | 17 | //线上环境 18 | const val RELEASE_URL = "https://api.github.com" 19 | } 20 | 21 | @Singleton @Provides fun baseUrl(): String = if(Settings.DEBUG) DEBUG_URL else RELEASE_URL 22 | } -------------------------------------------------------------------------------- /code/Kt15/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.5-2' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | testCompile group: 'junit', name: 'junit', version: '4.11' 27 | } 28 | -------------------------------------------------------------------------------- /code/Kt15/src/main/kotlin/net/println/kt15/SAMConversion.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt15 2 | 3 | /** 4 | * Created by benny on 12/17/16. 5 | */ 6 | fun main(args: Array) { 7 | val samInJava = SAMInJava() 8 | val lambda = { 9 | println("Hello") 10 | } 11 | samInJava.addTask(lambda) 12 | samInJava.addTask(lambda) 13 | samInJava.addTask(lambda) 14 | samInJava.addTask(lambda) 15 | samInJava.addTask(lambda) 16 | 17 | samInJava.removeTask(lambda) 18 | samInJava.removeTask(lambda) 19 | samInJava.removeTask(lambda) 20 | samInJava.removeTask(lambda) 21 | samInJava.removeTask(lambda) 22 | } -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/kotlin/net/println/kotlin/mybatis/TestUnsafe.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.mybatis 2 | 3 | import sun.misc.Unsafe 4 | 5 | /** 6 | * Created by benny on 3/26/17. 7 | */ 8 | 9 | class Test{ 10 | init { 11 | println("init") 12 | } 13 | 14 | companion object{ 15 | init { 16 | println("cinit") 17 | } 18 | } 19 | } 20 | 21 | fun main(args: Array) { 22 | val field = Unsafe::class.java.getDeclaredField("theUnsafe") 23 | field.isAccessible = true 24 | val unsafe = field.get(null) as Unsafe 25 | unsafe.allocateInstance(Test::class.java) 26 | 27 | } -------------------------------------------------------------------------------- /code/Kt10/src/main/kotlin/net/println/kt10/kotlin/LazyNotThreadSafe.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt10.kotlin 2 | 3 | /** 4 | * Created by benny on 11/13/16. 5 | */ 6 | class LazyNotThreadSafe { 7 | 8 | companion object{ 9 | val instance by lazy(LazyThreadSafetyMode.NONE) { 10 | LazyNotThreadSafe() 11 | } 12 | 13 | //下面是另一种等价的写法, 获取单例使用 get 方法 14 | private var instance2: LazyNotThreadSafe? = null 15 | 16 | fun get() : LazyNotThreadSafe { 17 | if(instance2 == null){ 18 | instance2 = LazyNotThreadSafe() 19 | } 20 | return instance2!! 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /code/Kt09/src/main/java/net/println/kt09/Tailrec.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt09 2 | 3 | import java.math.BigInteger 4 | 5 | /** 6 | * Created by benny on 11/6/16. 7 | */ 8 | class Result(var value: BigInteger = BigInteger.valueOf(1L)) 9 | 10 | 11 | tailrec fun factorial(num: Int, result: Result){ 12 | if(num == 0) result.value = result.value.times(BigInteger.valueOf(1L)) 13 | else { 14 | result.value = result.value.times(BigInteger.valueOf(num.toLong())) 15 | factorial(num - 1, result) 16 | } 17 | } 18 | 19 | fun main(args: Array) { 20 | val result = Result() 21 | factorial(1000000, result) 22 | println(result.value) 23 | } -------------------------------------------------------------------------------- /code/Kt03/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | jcenter() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 27 | testCompile group: 'junit', name: 'junit', version: '4.11' 28 | } -------------------------------------------------------------------------------- /code/Kt15/src/main/java/net/println/kt15/Generics.java: -------------------------------------------------------------------------------- 1 | package net.println.kt15; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by benny on 12/17/16. 8 | */ 9 | public class Generics { 10 | 11 | public abstract class View

{ 12 | P presenter; 13 | } 14 | 15 | public abstract class Presenter{ 16 | V view; 17 | } 18 | 19 | public static void main(String... args) { 20 | List list = new ArrayList(); 21 | list.add("Hello"); 22 | list.add(0); 23 | for (Object o : list) { 24 | System.out.println(o); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /code/Kt04/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 27 | testCompile group: 'junit', name: 'junit', version: '4.11' 28 | } 29 | -------------------------------------------------------------------------------- /code/Kt09/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.5 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 27 | testCompile group: 'junit', name: 'junit', version: '4.11' 28 | } 29 | -------------------------------------------------------------------------------- /code/Kt15/src/main/java/net/println/kt15/SAMInJava.java: -------------------------------------------------------------------------------- 1 | package net.println.kt15; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Created by benny on 12/17/16. 7 | */ 8 | public class SAMInJava { 9 | 10 | private ArrayList runnables = new ArrayList(); 11 | 12 | public void addTask(Runnable runnable){ 13 | runnables.add(runnable); 14 | System.out.println("After add: " + runnable + ", we have " + runnables.size() + " in all."); 15 | } 16 | 17 | public void removeTask(Runnable runnable){ 18 | runnables.remove(runnable); 19 | System.out.println("After remove: " + runnable + ", only " + runnables.size() + " left."); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /code/MyBatisIssue/src/main/kotlin/net/println/kotlin/mybatis/Main.kt: -------------------------------------------------------------------------------- 1 | package net.println.kotlin.mybatis 2 | 3 | import org.apache.ibatis.io.Resources 4 | import org.apache.ibatis.session.SqlSessionFactoryBuilder 5 | 6 | 7 | /** 8 | * Created by benny on 3/25/17. 9 | */ 10 | fun main(args: Array) { 11 | val resource = "net/println/kotlin/mybatis/config.xml" 12 | val inputStream = Resources.getResourceAsStream(resource) 13 | val sqlSessionFactory = SqlSessionFactoryBuilder().build(inputStream) 14 | val session = sqlSessionFactory.openSession() 15 | session.use { session -> 16 | val mapper = session.getMapper(UserMapper::class.java) 17 | val user = mapper.selectUser(1) 18 | println(user) 19 | } 20 | } -------------------------------------------------------------------------------- /code/Kt12/src/main/kotlin/net/println/kt12/Api.kt: -------------------------------------------------------------------------------- 1 | package net.println.kt12 2 | 3 | import com.google.gson.Gson 4 | import com.google.gson.reflect.TypeToken 5 | import java.lang.reflect.Proxy 6 | 7 | /** 8 | * Created by benny on 12/4/16. 9 | */ 10 | interface Api { 11 | fun getSingerFromJson(json: String): BaseResult 12 | } 13 | 14 | object ApiFactory { 15 | val api: Api by lazy { 16 | Proxy.newProxyInstance(ApiFactory.javaClass.classLoader, arrayOf(Api::class.java)) { 17 | proxy, method, args -> 18 | val responseType = method.genericReturnType 19 | val adapter = Gson().getAdapter(TypeToken.get(responseType)) 20 | adapter.fromJson(args[0].toString()) 21 | } as Api 22 | } 23 | } -------------------------------------------------------------------------------- /code/Kt12/build.gradle: -------------------------------------------------------------------------------- 1 | group 'net.println' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.0.4' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.6 19 | targetCompatibility = 1.6 20 | repositories { 21 | jcenter() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 26 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 27 | compile "com.google.code.gson:gson:2.7" 28 | testCompile group: 'junit', name: 'junit', version: '4.11' 29 | } 30 | -------------------------------------------------------------------------------- /code/RealmIssue/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 |