We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, what exactly is the difference between declaring variables seperately, e.g.
int a; int b;
and declaring them this way:
int a, b;
?
none
@goldey --
You can do this:
int a; int b; int c; a = 2; b = 4; c = 6; println(a,b,c);
or:
int a, b, c; a = b = c = 6; println(a,b,c);
int a=2, b=4, c=6; println(a,b,c);
...and the you end up with three declared and assigned variables using any approach.
However, if you mix types:
int a; int b; String c;
...you cannot declare or assign then together with commas:
int a, b, String c; // WRONG int a=2, b=4, c="x"; // WRONG
int a,b,c=a=b=6;
Answers
none
@goldey --
You can do this:
or:
or:
...and the you end up with three declared and assigned variables using any approach.
However, if you mix types:
...you cannot declare or assign then together with commas:
int a,b,c=a=b=6;