kotlin not among Java wording
Constructor
- Java class constructor and the same name, Kotlin using
constructor
FIG. - No public constructor in Kotlin modification, because the default visibility is public.
init
final
- Member variable val for read-only
- The default is the type parameter val
- Local variables
val custom getter
static property/function
-
object (singleton, and implements the interface inheritance, anonymous class)
-
companion object
top-level property/function声明
constant
- Kotlin constants must be declared in the object (including the associated objects) or "top-level top-level" because constants are static.
- Kotlin new modified constant
const
keyword. - Kotlin only primitive types and String types can be declared as constants.
Arrays and collections
- Array:
- Kotlin in the array has a generic class, create a function is a generic function, and aggregate data types.
- Values and modify
- It does not support covariant
- set
- Kotlin and Java as there are three collection types: List, Set, and Map
- Values and modify
- Variable set / set immutable
- In addition to the set of Kotlin also introduces a new type of container
Sequence
, and it isIterable
the same as used to iterate through a set of data and can be processed for each specific element
Visibility modifiers
public
: Open, maximum visibility, where can reference.private
: Private, minimal visibility, visible in visible and can be divided into classes according to different files declared position.protected
: Protection equivalent toprivate
+ subclass visible.internal
: Internal, visible only within the module.
reference