logo-MindMajix
PostKotlinKotlin
A
Anusha V

Posted on 24th July 2024|45 views

0
votes

Kotlin Switch Statement

What is the switch statement in kotlin?

1 answers
Answers
P
Sowjanya Kodiganti

Posted on 24th July 2024| views

A standard switch statement is just a statement that substitutes a range of simple if/else that performs necessary checks but it cannot replace all kind of if/else series it can only replace those which compare a value with some constant.

A small example of a switch statement is given below:

switch(choice)

{

case 1:

system.out.println(“fruits”);

case 2:

system.out.println(“leaves”);

case3:

system.out.println(“branches”);

default:

system.out.println(“not a tree”);

}

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number