Friday, 15 May 2015

java - evaluating variable int/string -



java - evaluating variable int/string -

int x = 20; double d = 3.1416; string s ="h";

those variables , have give type next lines evaluate to.

d/x + "";

is evaluating double variable type (0.15708), correct?

you'd right if didn't have pesky "" @ end!

add "" end of makes string. can handy shortcut - instead of having utilize string.valueof(), 4/2 + "", makes string.

to reiterate,

d/x double, since adding floating point.

but double + "" = string.

i hope helps. luck :)

java string

No comments:

Post a Comment