• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

doubt in Enum using switch case  RSS feed

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the below code compile and run fine and gives the output :
POOR Performance, Revised Salary = 100.0
AVERAGE Performance, Revised Salary = 105.0
GOOD Performance, Revised Salary = 120.0
EXCELLENT Performance, Revised Salary = 145.0

but I just want to clarify that in this code switch case is used without break why fall - through didnt happen and explain me how switch is working here.


Please help me understanding above code
Thanks in advance

[ July 25, 2007: Message edited by: Divya Gehlot ]
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi divya!



since you are using a return statement with every case label hence fall through dowsnot occurs and once the match is found the control transfers back to calling method..

change your code to...



now you might see the fall through occur...

this is the o/p i got with the changed code of raise()..



hope you got it !!
[ July 25, 2007: Message edited by: Priyam Srivastava ]
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Priyam
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!