zondag 17 april 2011

Using Switch in Java.

I could not remember how to use switch in Java. So I will place a example on my blog.

Example 1

switch(Variable) {
case VariableContents: Do things...
default: Do things..
}

Example 2

switch (month)
{
case 11:
numDays = 30;
break;
default:
System.out.println("Invalid month.");
break;
}

Geen opmerkingen:

Een reactie posten