admin 發表於 2019-12-8 22:20:07

Kotlin vs Java: Head to Head Comparison

Kotlin vs Java: Head to Head Comparison

FeatureJavaKotlin
Checked ExceptionsAvailableUnavailable
Code ConcisenessCan’t be labeled as conciseBetter than Java
CoroutinesUnavailableAvailable
Data ClassesRequired to write a lot of boilerplate codeRequires adding only the data keyword in the class definition
Extension FunctionsUnavailableAvailable
Higher-Order Functions and LambdasHigher-order functions are implemented using Callables. Lambdas expressions are introduced in the Java 8Comes as one of the prebuilt features
Implicit Widening ConversionsAvailableUnavailable
Inline FunctionsUnavailableAvailable
Native Support for DelegationUnavailableAvailable
Non-private FieldsAvailableUnavailable
NullPointerExceptionsAvailableUnavailable
Primitive TypesVariables of a primitive type aren’t objectsVariables of a primitive type are objects
Smart CastsUnavailableAvailable
Static MembersAvailableUnavailable
Support for ConstructorsCan’t have secondary constructors. Although, can have multiple constructors (constructor overloading)Can have one or more secondary constructors
Ternary OperatorAvailableUnavailable
Wildcard TypesAvailableUnavailable, has declaration-site variance and type projects as an alternative

頁: [1]
查看完整版本: Kotlin vs Java: Head to Head Comparison