I am struggling with bug in my program. and finally i got the point. here integer shows value 1 at the time of declaration. I clean and build again. but it shows 1 value?
please any one explain me why this happen?
I am struggling with bug in my program. and finally i got the point. here integer shows value 1 at the time of declaration. I clean and build again. but it shows 1 value?
please any one explain me why this happen?
When you declare a local variable without specifying a value, you need to assign it first before reading from it becomes valid. The 1
that you see in your integer variable could be any garbage value, it is unspecified. Reading this value is undefined behavior.
int numberOfRecords = 0;
This is different from instance variables, which are initialized by default.