Most voted "kotlin" questions
Kotlin is a statically typed programming language compatible with JVM and Javascript.
Learn more…234 questions
Sort by count of
-
39
votes2
answers3085
viewsWhat are the main differences between Kotlin and Java?
I have long been aware of the existence of the Kotlin language. I know that you need JVM to run and that it is completely interoperable with Java. At the time I did not give her much attention but…
-
27
votes1
answer4649
viewsWhat is it, Kotlin?
I’ve heard a lot about Kotlin. What is this? Is it a programming language? If so: What are the main features? Can I program on any operating system? And run? How do the guys in it work? I don’t want…
-
26
votes1
answer2059
viewsWhat are the coroutines?
What I’ve been given to understand is that it’s a new way of writing asynchronous code, allowing you to avoid blocking the thread. This leads me to assume that they are an alternative to class…
-
18
votes2
answers837
viewsWhat is the equivalent of the equalsIgnoreCase() in Kotlin?
What is the equivalent of the method String.equalsIgnoreCase() of Java in Kotlin?
-
17
votes1
answer632
viewsWhat are the main differences between Kotlin and Scala?
It is already clear differences between Kotlin and Java, such as: More concise (up to 40% code reduction) Null Safety Type inference Data class Interoperable with Java However, all these features…
-
14
votes1
answer920
viewsWhat’s the point of double exclamation before the method call on Kotlin?
I’m studying Kotlin. I realized that in converting to the type int, it is necessary to place the double exclamation (!!). Example: var input = readLine()!!.toInt(); Generally in other languages,…
-
14
votes1
answer994
viewsWhat are Raw Types?
Reading and studying a little about Kotlin, I found the following statement: The Raw Types are a big problem, but for reasons of compatibilities they had to be maintained in Java, but Kotlin for…
-
12
votes2
answers214
viewsWhat is the difference of var between Kotlin and Java?
With the release of Java 10, the possibility of using the var: var list = new ArrayList<String>(); I’ve seen the difference between val and varin Kotlin, but I would like to know more about…
-
11
votes1
answer961
viewsWhat makes Kotlin a language faster than Java?
I have read in some articles that Kotlin is faster than Java, but none of them exemplifies why. [...] As fast as Java". Kotlin - Evolve your Java Code (TDC-2016) Alex Magalhaes [...] Kotlin should…
-
10
votes1
answer4428
viewsWhat’s the difference in Kotlin between var and val?
Learning Kotlin I came across the following doubt, according to the documentation: Classes in Kotlin can have properties. These can be declared as mutable, using the var keyword or read-only using…
-
10
votes1
answer257
viewsWhat are extended functions?
I’m writing an article on programming in Kotlin, I came across this name, which are extended functions?
android function terminology characteristic-language kotlinasked 7 years, 1 month ago Lucas Vieira 397 -
10
votes2
answers753
viewsWhat does the exclamation mark mean after a guy’s name?
I have seen a lot in Kotlin types marked with an exclamation mark at the end. Especially when I use Java’s API. Something like CharSequence! What does that mean?…
-
9
votes1
answer420
viewsHow can I "postpone" the startup of a property?
There are situations where the property initialization is not possible to be made in the declaration, its value is only known later. An example of this is, on Android, references to views of a…
-
9
votes1
answer242
viewsWhat is the difference between init and constructor?
I’m starting to learn Kotlin and I’d like to know the difference between init and constructor, or set directly in the example class: class House(var cor: String, var vagaGaragem: Int)…
kotlinasked 5 years, 9 months ago João Vitor Camargo de Alemida 151 -
8
votes2
answers308
viewsWhy does Kotlin use a way of declaring functions and variables other than "traditional"?
Traditionally the return type and variable type are indicated at the beginning, before the name: public int soma(int a, int b){ return a + b; } In Kotlin he is named after: fun sum(a: Int, b: Int):…
function characteristic-language kotlin variable-declarationasked 7 years, 4 months ago ramaral 44,197 -
8
votes3
answers213
viewsWhat’s a Kotlin label for?
In an example of loops in kotlin documentation, we have some codes with the following excerpt: loop@ for (i in 1..100) { for (j in 1..100) { if (...) break@loop } } From what I read in the…
-
8
votes2
answers335
viewsHow to customize the getter in Kotlin?
When we create a variable of type val, in the case of Java, only the getter relative to it. Different when a type variable is created var, in which the getter and setter. See below for an example:…
-
8
votes4
answers3000
viewsEquivalent to the conditional or ternary operator in Kotlin
Below I am logging on the monitor of Android Studio in JAVA a short phrase using conditional or ternary operator (?)en. Look at: Log.wtf(GOT, (valirianSteel == 0 && glassOfDragon==0) ?…
-
8
votes3
answers8606
viewsSwitch case Kotlin
In Java I use the switch in various situations, as in the example below: public class SwitchDemo { public static void main(String[] args) { int month = 8; String monthString; switch (month) { case…
-
8
votes1
answer775
viewsHow to have multiple languages in a single application?
Listening to a technology podcast on Nubank, CTO and Principal Engineer comment that they use Java, Kotlin, React Native and Flutter to develop the Android app and everything generates a single…
android react-native software-architecture kotlin flutterasked 5 years, 6 months ago Alisson Marqui 1,128 -
8
votes1
answer380
viewsHow to remove the background of an image using Watershed on android?
I’m developing an app that classifies images of wounds. For this, I need to highlight the region of interest of the background to facilitate the work of the classification algorithm. The user uses…
-
6
votes1
answer75
viewsEarly return of a fold
Kotlin allows returns for previously declared tags, including implicit labels. Example of documentation: fun foo() { ints.forEach { if (it == 0) return@forEach print(it) } } In that spirit, I would…
kotlinasked 8 years, 11 months ago Anthony Accioly 20,516 -
6
votes1
answer441
viewsWhat is the difference between Kotlin data class and Scala case class?
In Scala we have case classes, for example: case class Pessoa(nome: String, sobrenome: String) and in Kotlin we have data classes: data class Pessoa( val nome: String, val sobrenome: String ) What’s…
-
6
votes2
answers296
viewsWhat is the Anko?
Already converting my Android projects to Kotlin, in some researches I’ve been doing, several times quoted a Anko Kotlin. What is this Anko? What is this about? What is your goal?
-
6
votes1
answer1794
viewsWhat is the purpose of "data class"?
In Kotlin it is possible to create a class as follows: data class Dragon(private val name: String, val glass: Int) What is the main objective of the data class in Kotlin? When should we use?…
-
6
votes3
answers171
viewsIs it possible to have properties other than those generated automatically in a data class?
Kotlin allows you to simplify the creation of what in Java we call POJO: data class Person(val firstName: String, val lastName: String) With this we get a class with the getter for all variables…
-
6
votes1
answer1727
viewsWhat is the difference between Type-safe and Null-safe?
I’m writing an article about Kotlin, and I came across these guys, if anyone can help me. What is the difference between Type-safe and Null-safe?
-
6
votes1
answer290
viewsGenerate an APK on a server
I was thinking of an architecture that would work as follows. The user would have a series of parameters to fill and generate code automatically, then to click on in a Buttom, be it in version web…
-
6
votes2
answers3586
viewsHow to initialize an array in Kotlin?
I need to initialize an array in Kotlin more do not know how to do, in Java I did so: int numeros[] = new int[] {0,1,3,4,5,6,7,8,9};
-
6
votes1
answer68
viewsAre Java enumerations anti-performance?
In a project I thought of exchanging whole ones for enumbut a colleague told me that enums are anti performatic.
-
5
votes3
answers1764
viewsHow to create a static method using Kotlin?
In JAVA when we want to create a static method, we use static. Look at: public static String getDragonGlass(){ return String.valueOf("All the dragon glasses."); } And in the Kotlin, how best to…
-
5
votes1
answer115
viewsWhat is Lazy instantiation?
I saw here on wakim’s response that code snippet: data class Person(val firstName: String, val lastName: String) { val fullName: String by lazy { "$firstName $lastName" } } What is this so-called…
-
5
votes1
answer1167
viewsHow to get a random number in Kotlin?
How can I get a random number between two values? Like ruby does with rand(0..n)
-
5
votes1
answer452
viewsIs it possible to compile an app using Java and Kotlin together?
Can I be part of the code in Java and another part with Kotlin? Can anyone tell me?
-
5
votes1
answer216
viewsWhat does the == operator mean in Kotlin?
What does the === Kotlin operator mean, and how to use it? I found this snippet of code in the documentation, but I was left with doubts. val boxedA: Int? = a val anotherBoxedA: Int? = a…
-
5
votes1
answer252
viewsAccess to object properties in a list (KOTLIN). Why is it so complicated?
I’m trying to do something that I think is extremely simple: Given a class called Student, i instated 3 students and added on a list (mutableListOf). That done, I want to access the name of the…
-
4
votes2
answers1398
viewsJava to Kotlin conversion
One of the qualities cited about the Kotlin language is the creation of clean code, that is, code that is pleasant to read and that can accomplish its goal without curling. From what I saw, Android…
-
4
votes2
answers1264
viewsHow to read a file with Kotlin?
I have a file .txt with some information I’d like to read to a string through Kotlin. I am a beginner in language and would like to know how to read a file with Kotlin.
-
4
votes1
answer781
viewsWhat is the purpose of the Ternal lateinit?
I converted to the Kotlin a simple Fragment with any button. In the alternation, it basically looked like this: Java private Button btn; Kotlin internal lateinit var btn: Button What is the purpose…
-
4
votes1
answer71
viewsWhat is the difference between two code snippets with and without a constructor?
I’m having trouble understanding what a constructor does. Does it initialize a variable so it’s not null? If yes, this would not be solved easily by doing what is written in the second code snippet?…
-
3
votes1
answer83
viewsWhy use "is" at variable start in Kotlin?
What is the reason for using the is in front of the variable. Example source code. I know it has something to do with the set. class Rectangle( val height: Int, val width:Int) { val IsSquare:…
-
3
votes1
answer121
viewsHow to make two Retrofit chain calls with Rxjava?
I make a call to recover some data and the second call - which should be made inside the first one - uses one of the fields of the previous call. val restApi = retrofit.create(RestAPI::class.java)…
-
3
votes4
answers3854
viewsfindViewById no Kotlin
I was generating an action by clicking on a Button fun cliqueBotao(view : View){ var texto = findViewById<>(R.id.textoExibicao) as TextView texto.setText("Texto alterado") } Only that Android…
-
3
votes2
answers129
viewsKotlin for Creation and Apis: Only for Android?
I saw some features offered by the Kotlin tool, especially when it comes to saving lines of code and verbosity generated in Java. How is the tool to generate services and be consumed by web…
-
3
votes3
answers559
viewsHow to know the type of a variable in Kotlin?
What is the function to know the type of a variable? ex: var a = "teste" print(a.type()) output: String
-
3
votes2
answers1046
viewsWhat is the difference between KTS and KT extensions?
I am studying Kotlin and opened a Spring Boot project out of curiosity. I came across two files of different extensions, contento code Kotlin: .kts and .kt. What is the difference between these two…
-
2
votes1
answer884
viewsError: "classify 'class name' does not have a Companion Object,"
My code fun main(args: Array<String>) { val listaDeLikes = listOf( RelacaoDeLike(323423,1), //Usuario 323423 deu like no post 1 RelacaoDeLike(234234,1), //Usuario 234234 deu like no post 1…
kotlinasked 7 years, 1 month ago Khallanak Ginovaef Arklaynnost 49 -
2
votes0
answers100
viewsError: Variables debug info not available
Whenever I try to "debug" with Android Studio this error appears: "variables debug info not available". Code in the Gradle: apply plugin: 'com.android.application' apply plugin: 'kotlin-android'…
-
2
votes1
answer156
viewsCan I export a JAR file with only Kotlin classes, without any Java class?
I’m using Intellij IDEA to develop a project in Kotlin, and I’ve reached a point where I need to create an executable file to run on the server, but when I try to create a JAR Artifact, I cannot…
-
2
votes3
answers290
viewsI cannot use class R. in Kotlin
I’m trying to learn Kotlin , but I’m having trouble importing the "R." class into Kotlin. Someone would know what I’m doing wrong ?…