Answers for "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
1

switch statement in java

// syntax of switch statement in java
switch(expression)
{
   case 1 value :
   // code goes here
   break;

   case 2 value :
   // code goes here
   break;

   case 3 value :
   // code goes here
   break;
   .
   .
   .
   .
   
   default: // optional
   // default code goes here
}
Posted by: Guest on November-25-2020
0

switch statement java

int age = 9;
switch(age){
  case 1:
    System.out.println("You are 1 year old");
  case 5:
    System.out.println("You are 5 years old");
  case 9:
    System.out.println("You are 9 years old");
  default:
    System.out.println("Ain't know how many years you are");
Posted by: Guest on July-27-2021
0

switch method in java

//import java.util.Scanner;
System.out.println("What day is today ? ");
		System.out.println("First Letter Capital");
		String  a =scanner.nextLine();
		
		switch(a) {
		case "Sunday": System.out.println("Its Sunday");
		break;
		case "Monday": System.out.println("Its Monday");
		break;
		case "Tuesday": System.out.println("Its tuesday");
		break;
		case "Wednesday": System.out.println("Its Wednesday");
		break;
		case "Thursday": System.out.println("Its Thursday");
		break;
		case "Friday": System.out.println("Its Friday");
		break;
		case "Saturday":System.out.println("Its holiday ");
		break;
Posted by: Guest on September-10-2021
0

switch cases: JAVA

int day = 4;
switch (w3exercise_input_no_0) {
  w3exercise_input_no_1 1:
    System.out.println("Saturday");
    break;
  w3exercise_input_no_2 2:
    System.out.println("Sunday");
    w3exercise_input_no_3;
  w3exercise_input_no_4:
    System.out.println("Weekend");
}
Posted by: Guest on September-03-2021
0

switch java

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 May-23-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language