Kotlin精选Kotlin禅与计算机程序设计艺术

What does Kotlin offers that Jav

2017-09-17  本文已影响57人  光剑书架上的书

What does java offers that Kotlin doesn’t

1.Checked exceptions - All exception classes in Kotlin are descendants of the class Throwable.
2.Primitive data types - Everything in Kotlin is an object .
3.Static members - Because, if you declare a companion object inside your class, you’ll be able to call it’s members with the same syntax as calling static methods/variables in Java.
4.Wildcard types - If you’re not familiar with it - In java you use bounded wildcards to increase API flexibility.

What does Kotlin offers that Java doesn’t

  1. Lambda expressions and Inline functions
  2. Extension functions
  3. Null Safety (No more annoying null exceptions)
  4. Smart casts (Yeah, typecasting is boring)
  5. String templates
  6. Properties
  7. Primary constructors
  8. First-Class delegation
  9. Singletons (many would argue, you could make singletons in Java, but that’s not officially supported).
  10. Range Expressions
  11. Operator Overloading (Good news for C++ developers)
  12. Companion objects
  13. Data classes
  14. Coroutines

And Kotlin is Simpler with engineering practicality than Scala.


There is a reason why Google has announced Kotlin as the official language for Android. If your focus is Android development, you should start learning it. It is worth the effort.

上一篇 下一篇

猜你喜欢

热点阅读