I am trying to write a switch statement which will check the return statements from 3 called up methods ("february", "century", and "leap")...and based on the boolean values they return to "daysInMonth" certain commands are to be carried out......
is ist possible to use the code segment below the way i have done? if not, what corrections could i make,....any suggestions?
because i was made to understand that if you had several "if statements" following each other you could put them all together into a switch control structure?
so if i have 20 possibilities i would have to put these all into "if statements"?
Booleans have just two values: true and false. Therefore a "boolean switch" could never have more than two branches. To have more than two branches, you'd actually need more than one boolean value -- i.e., you're testing more than one thing. A chain of if... else if... else statements lets you do just that.
Wolf- Just a little switch tip. If you're going to take the same action for several cases, it is not necessary to explicitly code the action for each case. Just arrange your cases appropriatley. The following will have the same affect as the switch you coded above.
Originally posted by S Root: Wolf- Just a little switch tip. If you're going to take the same action for several cases, it is not necessary to explicitly code the action for each case. Just arrange your cases appropriatley. The following will have the same affect as the switch you coded above.
why don't we have a break after the If condition below if (((isSchalt == true)&&(!(isCent)))||(isLeapCent == true)) days = dayGroup[1];
It is good programming style to always write the curly braces, {}, althought they are not needed if the clause contains only a single statement. The curly braces are a general indicator in Java of a compound statement. This is known as a block of code. (See here) [ May 29, 2006: Message edited by: wise owen ]