Im learning java from basics. One of the book they claimed
int h = f = 10;
will work but in real time its not working. Please explain.
My code:
int h = f = 10;
Why it is not working?
Im learning java from basics. One of the book they claimed
int h = f = 10;
will work but in real time its not working. Please explain.
My code:
int h = f = 10;
Why it is not working?
Try this :
int h, f;
h = f = 10;
but keep in mind, this will only work with immutable objects, like Integer
or String
. You cannot use the same for an object of a class because they would be pointing on the same instance and if you modify one, you'll modify the others !
Because f
is not declared yet. This will work:
int f, h;
h = f = 10;