x, y, z = 4, 64, 4
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Java] Multiple vars in one line
Started by svdragster, 09 July 2013 - 01:56 PMPosted 09 July 2013 - 03:56 PM
Hey, does anyone know if something like this is possible in Java, too?
Posted 09 July 2013 - 04:01 PM
why not assign them like this?
int x = 4,y = 64, z = 4;
Posted 09 July 2013 - 04:01 PM
You can if they're all the same type, the syntax is…
int x=4, y=64, z=4;
Posted 10 July 2013 - 03:43 AM
Provided they're all the same value and type, you can also do shit like
int x = y = z = 4;
Posted 10 July 2013 - 04:09 AM
Provided they're all the same value and type, you can also do shit likeint x = y = z = 4;
You actually can't do it like that. Y and Z are undefined and that will error
Posted 10 July 2013 - 04:52 AM
Wasn't it introduced in 1.7?
Posted 10 July 2013 - 04:57 AM
I always have the latest version of Java and my Eclipse errors:
Multiple markers at this line
- z cannot be resolved to a
variable
- y cannot be resolved to a
variable
Posted 10 July 2013 - 09:26 AM
Posted 10 July 2013 - 10:58 AM
I thought it was
int x, y, z = 2;
Posted 10 July 2013 - 11:45 AM
That would declare all three, but leave x and y un-initialised.I thought it wasint x, y, z = 2;
Posted 11 July 2013 - 06:15 AM