Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Switch statement: Illegal start of expression (huh?!)

 
Greenhorn
Posts: 12
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone fix this code for me?



Thanks.
 
Sheriff
Posts: 3108
459
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably mean default: not case default:

The Java™ Tutorials - The switch Statement
 
Master Rancher
Posts: 3537
39
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thomas Mahoney wrote:


You've commented out the closing brace here.
 
Bartender
Posts: 732
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that there is no need for curly braces inside each case-block. So:
Also noted that I include a "break" statement in the defauot clause. The reason for this is that it is not required for the default clause to come after all of the case clauses (but it is usually considered good practice to do so).
 
Ranch Hand
Posts: 53
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.

change to


2.

change to


example:

en.verejava.com/?id=20047960488848
 
Marshal
Posts: 69403
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does line 37 mean? I think it will cause you trouble.
 
joseph hu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please delete



may be dead loop.
 
Thomas Mahoney
Greenhorn
Posts: 12
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, guys.  I fixed it, and you helped a lot.  Oh, and line 37 is the tail end of a Do While loop meant to repeat this entire switch statement while the enclosed variable's value is greater than 0, only I didn't include the entire loop statement.

Thanks Again.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great job!  Would you mind posting your final code so that others can benefit from it?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while (choice >= 1); why this condition??
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thomas Mahoney wrote:...  Oh, and line 37 is the tail end of a Do While loop meant to repeat this entire switch statement while the enclosed variable's value is greater than 0, only I didn't include the entire loop statement....

 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic