GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 399 of 493    Print  
If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?

  
Total Answers and Comments: 9 Last Update: May 04, 2008     Asked by: Raj 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 11, 2008 07:54:46   #1  
sampra Member Since: February 2008   Contribution: 279    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
yes we can do
 
Is this answer useful? Yes | No
March 18, 2008 13:14:02   #2  
lhariPrasad Member Since: September 2006   Contribution: 25    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
I don't think so there are any other alternative algorithm or logics ? if any even I am also interested to know !
 
Is this answer useful? Yes | No
March 19, 2008 04:44:33   #3  
Arnab.infinity Member Since: March 2008   Contribution: 3    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
Using '?' Operator
 
Is this answer useful? Yes | No
March 19, 2008 14:44:41   #4  
trinadh Member Since: March 2008   Contribution: 4    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
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
            }
        }

 
Is this answer useful? Yes | No
March 21, 2008 01:18:14   #5  
sampra Member Since: February 2008   Contribution: 279    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
we can use conditonal operator ?
 
Is this answer useful? Yes | No
March 25, 2008 08:56:08   #6  
tarunsen.indore Member Since: March 2008   Contribution: 1    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
Switch Case for too many cases of ifelse
in 2 or 3 cases we can use ? ternary

 
Is this answer useful? Yes | No
March 27, 2008 01:22:16   #7  
nihlist Member Since: March 2008   Contribution: 1    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
Switch cases are the best things to be used; using too much of ternary operators can make the things complicated.
 
Is this answer useful? Yes | No
April 01, 2008 03:14:11   #8  
poonamjava Member Since: December 2006   Contribution: 20    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
We can use ternary (?) operator.

poonam

 
Is this answer useful? Yes | No
May 04, 2008 20:10:51   #9  
lhariPrasad Member Since: September 2006   Contribution: 25    

RE: If there are multiple If-else, what is the alternative algorthim we can use apart from using switch?
I think ternery operation takes only one statement, but what if you want to exectue multiple statemetns !

cheers....hari

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape