• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

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

 
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.
 
Saloon Keeper
Posts: 2504
321
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • 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
 
Ranch Hand
Posts: 3218
19
  • 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: 700
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: 35
  • 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: 64171
215
  • 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: 35
  • 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: 5931
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • 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: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while (choice >= 1); why this condition??
 
Knute Snortum
Sheriff
Posts: 5931
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • 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....

 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!