Interoperabilidad Kotlin-Java
Llamar a Java desde Kotlin y entender cómo Kotlin se compara con Java. Tipos de plataforma, nulabilidad, conversiones SAM y más.
- Paso 1
Comparación con Java
Kotlin fixes a series of issues that Java suffers from....
Comenzar lección - Paso 2
Llamar a Java desde Kotlin
Kotlin is designed with Java interoperability in mind. Existing Java code can be called from Kotlin ...
Comenzar lección - Paso 3
Llamar a Kotlin desde Java
Kotlin code can be easily called from Java. Instances of a Kotlin class can be created and used in J...
Comenzar lección - Paso 4
Usar Records de Java en Kotlin
Records in Java are classes for storing immutable data with a fixed set of components. They have con...
Comenzar lección - Paso 5
Strings en Java y Kotlin
This guide shows how to do typical string tasks in Java and Kotlin, to help you migrate and write id...
Comenzar lección - Paso 6
Colecciones en Java y Kotlin
Collections are groups of a variable number of items that are significant to the problem and commonl...
Comenzar lección - Paso 7
Nullability en Java y Kotlin
Nullability is the ability of a variable to hold null. Dereferencing null causes NullPointerExceptio...
Comenzar lección - Paso 8
Entrada estándar
Java Scanner is slow; use it only when you need its specific features (e.g. hasNext(), useDelimiter(...
Comenzar lección - Paso 9
Caja de herramientas de anotaciones @Jvm: cuándo usar cada una
When you publish Kotlin code that Java teammates will consume, the @Jvm annotations control how your...
Comenzar lección - Paso 10
Tipos de plataforma y anotaciones de nullability
Every reference in Java can be null, but most Java code carries no nullability information. When Kot...
Comenzar lección - Paso 11
Conversiones SAM y fun interface
A SAM (Single Abstract Method) interface has exactly one abstract method — Runnable, Callable, Compa...
Comenzar lección - Paso 12
Llamar a Kotlin desde Java en profundidad
Java cannot see Kotlin the way Kotlin sees itself: there are no top-level functions, no companion ob...
Comenzar lección - Paso 13
@Throws y excepciones comprobadas
Kotlin has no checked exceptions: every exception is unchecked, and the compiler never forces you to...
Comenzar lección - Paso 14
Interop de genéricos: varianza y wildcards
Java expresses variance at the use site with wildcards (? extends T, ? super T). Kotlin prefers decl...
Comenzar lección - Paso 15
Interop de colecciones y arreglos
Kotlin splits Java's single List into two views: a read-only List<T> and a MutableList<T>. They are ...
Comenzar lección - Paso 16
Interop de propiedades: getters, setters y targets de accesores
Kotlin properties and Java accessor methods are two views of the same idea. A Java getX()/setX() pai...
Comenzar lección - Paso 17
Interop de vararg y el operador spread
A Kotlin vararg parameter and a Java varargs parameter (T...) compile to the same thing on the JVM: ...
Comenzar lección - Paso 18
Llamar a builders y APIs fluidas de Java desde Kotlin
Many Java libraries use the builder pattern: a chain of methods that each return this (or a new buil...
Comenzar lección - Paso 19
Coroutines y funciones suspend desde Java
A Kotlin suspend function cannot be called directly from Java: under the hood the compiler adds a hi...
Comenzar lección - Paso 20
Funciones de alcance para un interop más limpio con Java
Kotlin's scope functions — let, run, with, apply, also — shine when you work with Java objects that ...
Comenzar lección - Paso 21
Puente con interfaces funcionales de Java y referencias a métodos
Java 8 added java.util.function interfaces — Function, BiFunction, Supplier, Consumer, Predicate, an...
Comenzar lección - Paso 22
Anotaciones, const y typealias a través de la frontera
Kotlin can declare and consume Java annotations. To create an annotation usable from both languages ...
Comenzar lección - Paso 23
Companion objects y @JvmStatic desde Java
Kotlin has no `static` keyword. The role of Java statics is played by companion objects, top-level f...
Comenzar lección - Paso 24
Clases selladas, when exhaustivo y switch de Java
A `sealed` class or interface restricts its subtypes to a known, closed set declared in the same mod...
Comenzar lección - Paso 25
Value classes en línea y @JvmInline
A value class wraps a single value to give it a distinct type — a `UserId` that is not interchangeab...
Comenzar lección - Paso 26
Argumentos por defecto y @JvmOverloads
Kotlin functions can declare default values for parameters, so one declaration covers many call shap...
Comenzar lección - Paso 27
Funciones de extensión vistas desde Java
An extension function lets you call `"abc".shout()` as if `shout` were a method on `String`, without...
Comenzar lección - Paso 28
Java Optional ↔ nullable de Kotlin
Java 8 introduced `Optional<T>` to express 'a value that may be absent'. Kotlin solves the same prob...
Comenzar lección