A type by value will always have assigned a value. You declared the variable and it entered the scope has a value. If the code does not define any it will be adopted the default value that is 0.
If you need to define whether a variable had a value and then passed or did not have another value, you have to control it separately in another variable: either telling if you had a value change; or what the original value was to see if it is still the same, which gives a slightly different semantics.
When a variable is worth 1 and you assign a value 1 in it you changed the value of the variable, but the result is the same, just make no mistake that there is another object there, but that has the same content. If you just want to know if the value is different have the previous value seems the most appropriate. If you want to know if a new value has been assigned to the variable, but it doesn’t matter if it has been changed, then a flag is more useful. The int?
has a flag, in some cases may be sufficient, as long as it does not let the value be null after.
You can create a guy to control that, but by description you can’t do this in this case.
Transform into
String
and then check the contents with the methodequals()
could not be?– R.Santos