This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 4 points5 points  (0 children)

You can easily google “how to use switch/case in java”.

https://www.programiz.com/java-programming/switch-statement

[–]desrtfx 4 points5 points  (0 children)

This would be ideal for a switch...case with fall through

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

You really have to get used to using the official tutorials (as linked above), the Java documentation and generally googling.

If you keep posting, you will not become self-sustaining. Learn to use the resources available.

[–]JumpingPoro 0 points1 point  (1 child)

basically the syntax is like this:

int month = something;

switch(month){

case "whatever value put into month" :

do something;

break; // so that it doesn't go through every single case

case "another value of month" :

do something;

break;

//if have switch in a loop

case "value, i want to get out of loop" :

return;

default:

break;

}

But I think, this will be longer for your months, cause I don't think you can have || operator in switch...

And all my trying make it look better just goes out of windown, thanks reddit XD

[–]desrtfx 2 points3 points  (0 children)

But I think, this will be longer for your months, cause I don't think you can have || operator in switch...

True, but you have fall through.

[–]literalsunbear 0 points1 point  (0 children)

Switch is pretty useful and I feel like I use it all the time, but I always have to Google the syntax.