• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

doubt in Enum using switch case

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Priyam
 
We're all out of roofs. But we still have tiny ads:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic