If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?

Showing Answers 1 - 39 of 39 Answers

trinadh

  • Mar 19th, 2008
 

we can go for ternary operator example
 if()                                                       c1?s1:c2?s2:c3?s3:.....
else{                                                       here c1 is condition one and s1  statement one
   if(){}                                                      like that . have u under stood...
    else{
       if() {}
            else
            }
        }

nihlist

  • Mar 27th, 2008
 

Switch cases are the best things to be used; using too much of ternary operators can make the things complicated.

  Was this answer useful?  Yes

Hariom Singh

  • Jan 25th, 2013
 

Using assertion keyword.

  Was this answer useful?  Yes

Govardhan

  • Feb 14th, 2013
 

I think switch case is better alternative instead of more if-else statements owing that another alternative ternary operator it would be complicated and a little bit of confusion thats why, I would prefer to go for switch case.

  Was this answer useful?  Yes

Prashant Shingne

  • Sep 9th, 2016
 

We can use OOPS Concept run-time binding to call expected functionality. No need of if clause, provided everything is represented in objects.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions