Linked Questions

3 votes
1 answer
6k views

Let's say I have something like this: var x : String = "str" // here do some with x, but not assign new value to it Then Android Studio tells me that x should be declared with val, not var. I know ...
J K's user avatar
  • 642
2 votes
1 answer
1k views

I am learning Spring Boot with kotlin and I am so confused with the usage of var or val for entity property. In some tutorial they use val and the other use var. So I don't know which is the right one ...
Denny Rustandi's user avatar
-1 votes
1 answer
774 views

In which case we have to use val instead of var ? I know val is when we know the value is not going to change. But I am under the impression that var is good for all case. Is that true ? In others ...
EagleStar's user avatar
  • 209
1 vote
1 answer
86 views

can someone explain to me the difference between a reference and a referenced object? Notice that the type of the variable reference (var, val) relates to the reference itself, not the properties of ...
Rezo Joglidze's user avatar
23 votes
3 answers
12k views

I am trying to learn Kotlin. What is val, var and internal in Kotlin compared to Java? In Java: RadioGroup radioGroup; RadioButton button; Button submit; After converting it shows: internal ...
Navjot.jassal's user avatar
8 votes
2 answers
3k views

This is actually 2 questions. I noticed that databinding doesn't work if in the Person data class I set the name parameter to be val instead of var. The code will break with the following error: ...
qeh63's user avatar
  • 81
8 votes
2 answers
10k views

I can use Code 1 to save MutableList<MDetail> to json string using Gson correctly, But I get the error when I try to restore MutableList<MDetail> object from json string with Code 2. I ...
HelloCW's user avatar
  • 2,655
2 votes
4 answers
2k views

I really want to know why Kotlin use the word val to stand for constant? If var means variable.val means what ? val means var + l or val is only one word for short? In the Kotlin Documentation,we ...
ifeegoo's user avatar
  • 7,382
0 votes
1 answer
14k views

The problem is that when I run my code the app is stopping with an error (java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twixt.pranav.pos/com.twixt.pranav.pos.View.Activity....
Pranav Ashok's user avatar
5 votes
2 answers
3k views

I have the following Kotlin code. A sealed class called Animal, and two object classes Dog and Cat inherits from the sealed class Animal. I am getting this error in the when clause in the is Cat case. ...
s-hunter's user avatar
  • 26k
5 votes
3 answers
4k views

I'm a beginner in Kotlin and I'm actually doing an Androïd application in Kotlin. I have to initalize some properties whose values are unknown (it isn't but it's hard to define from now) so I'd like ...
Tanguy Epifanic's user avatar
1 vote
1 answer
4k views

I am working on simple Spring Boot service with Kotlin, and PostgreSql. I use JPA. Currently I have two tables "users", and "expenses", "expenses" table have reference to "users" id: CREATE TABLE ...
Domas A.'s user avatar
  • 135
0 votes
1 answer
888 views

I want to get data from the cloud firestore and have to store it to a string variable but unable to do so and need help. This is below code val db = FirebaseFirestore.getInstance() val ...
Rajat Gupta's user avatar
0 votes
1 answer
334 views

I'm new to Kotlin and I've been reading a lot about how val is read-only and var is mutable. That's fine i get it. But what's confusing is when you create a mutable lsit/map/array and you've assigned ...
Asad Nawaz's user avatar
0 votes
1 answer
437 views

I'm trying to change height and width of ListView item programmatically, but I'm getting an "val cannot be reassigned error", can you please tell me witch exact val can't be reassigned here and how ...
Danila says Reinstate Monica's user avatar

15 30 50 per page