Need a little bit of help with syntax here. I\'m trying to re-initialize multiple variables after the type has already been defined. So for example
int bonus, sa
I think you are confused as to be behavior of int bonus, sales, x, y = 50;
. It initializes y
to 50
and leaves the rest uninitialized.
To initialize all of them to 50
, you have to:
int bonus = 50, sales = 50, x = 50, y = 50;
You can then change their values:
bonus = 25;
x = 38;
sales = 38;
// or compact
bonus = 25; x = 38; sales = 38;
// or to same value
bonus = x = sales = 42;
Unlike the C
language where you can use the comma syntax anywhere, in Java you can only use that when declaring the variables, or in a for
loop: for (i=1, j=2; i < 10; i++, j+=2)
int bonus = 25;
int x = 38; // or any other value you prefer
int sales = 38;
later you can access the variables
bonus = 35; // and so on...
Method: you can use it, this way.
int bonus=50; sales=50; x=50; y = 50;
In your code only y has been initialized.
if any help visit: http://wwww.logic4code.blogspot.in/