Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I can't make variables work Android Studio

I have learned the java basics and am now trying to make an android app for my phone. I was doing fine up until I started using variables in android studio. Im fairly sure variables are meant to be declared like

var/val varName:Boolean false;

But whenever I do this I get an error saying "Cannot resolve symbol var".

I have researched but I cannot find any reason this is happening and no matter where I put this line of code it does not work. Everywhere I found online seems to say I’m doing it right but it doesn’t work.
I would love any adviceor how to make it work.
Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This post is kinda confusing, in what language are you creating the app, java or kotlin? the syntax looks like Kotlin, but you are stating that you know Java basics (nothing said about kotlin)

Anyways, In kotlin, in order to create a variable you would do something like:

val a: Int = 1 // this is a VALUE, you cannot change the value of "val"
val b = 2  // this is also a value
var c = 2 // this is a variable, you can change the value of c
c = 5 // like I did here

var name: Boolean = false // and that's what I think you've tried to do
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading