Using switch in java...help please?

Ruffian998

Member
Feb 9, 2005
25
0
0
I was wondering how I would go about changing this if - else statement into the equivalent switch statement:


if (i == 1 || i = 2)
output = "small";
else if (i == 3)
ouput = "medium";
else
output = "large";
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
switch (i) {

case 1:
case 2: output = "small";
break;

case 3: output = "medium";
break;

default: output = "large";
break;

}

bah! beaten to the punch.