Answers for "what to use instead of switch case in java"

83

java switch

int day = 4;
switch (day) {
  case 6:
    System.out.println("Today is Saturday");
    break;
  case 7:
    System.out.println("Today is Sunday");
    break;
  default:
    System.out.println("Looking forward to the Weekend");
}
// Outputs "Looking forward to the Weekend"
Posted by: Guest on March-11-2020
0

switch case less than java

switch (lessThan)
	{
    
    //Less than cannot techinically be added so we use the numbers less than those numeberss
		case 1:
		case 2:
		case 3:
		System.out.println("This name has 3 or less characters");
		break;

		case 4:
		System.out.println("This name has 4 characters");
		break;
    
	}
Posted by: Guest on November-03-2020

Code answers related to "what to use instead of switch case in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language