Paulius Kukulskis wrote:I thank you for your help. Much appreciated. I followed on every advise you gave me. Now, I have a question. When "extracting" float value from object of type Object is it better to use cast or .toString method?
Invoking the
toString() method will not give you a float, but it gives you a String. So using
instanceof operator and a cast will be the only way to go.
But maybe you could use this method signature and make sure you pass the appropriate arguments to this method
And you should definitely use meaningful variable names, because
a,
b, and
c make it very hard to read (and maintain) your code; I think we can agree
columnName,
newValue, and
id are 1000x more meaningful.
And another tip I like to share: if you are using
Java 7 or beyond, you should use
try-with-resources statement. Using this Java 7 feature you don't have to care about closing your resources anymore, it will be done automatically for you.
Hope it helps!
Kind regards,
Roel