0

A variable is not initialized

What does it mean and what I have to correct in program ❓❓

18th May 2019, 12:46 PM
Shiksha Bajpayee
Shiksha Bajpayee - avatar
5 Réponses
0
Assuming you're doing object oriented compiled programming (java, c++, etc..) Well they're two kind of data types in programming. There's the primitive ones and the objects. If we declare a primitive type variable (like int, boolean, ...) without giving it a value, It will have a default value (0, false, ...) On the contrary, more complicated data types (objects) will not have a default value but a null value (value = null), and the comoilator warns you about it To correct it, simply give it a value when you declare it.
18th May 2019, 12:54 PM
ThewyShift
ThewyShift - avatar
0
Please link the code in the post😶 It means that you tried to access a variable and the system couldnt find it For example (Python example) print(m) m = "hello" It will raise an error because m didn't "exist" yet
18th May 2019, 12:58 PM
Trigger
Trigger - avatar
0
it means you should initialize the variable before using it eg- int a; // this is declaration a=20; // this is initialization or int a=20;
18th May 2019, 3:36 PM
kiRA
kiRA - avatar
0
ThewyShift sorry but you are wrong. Only Instance variable and Static variable gets a default value if not initialized. You need to initialize local variable before using it.
18th May 2019, 3:50 PM
kiRA
kiRA - avatar
0
kiRA Mmh gotta do some testing but that might indeed be true ! Thanks for the correction
18th May 2019, 3:53 PM
ThewyShift
ThewyShift - avatar