• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: Syntax error, insert "}"

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im trying to do my own little text game
and i almost done
but i dont know what to do with this error
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Syntax error, insert "}" to Complete ClassBody
if a add an "}" the whole code breaks.
how can i solve this?
package juego;

import java.awt.Color;
import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

 
Marshal
Posts: 77157
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please tell us the line the error appears on. Please get your code correctly formatted (which your IDE will do automatically): look at line 49. that sort of formatting error makes it impossible to work out where the { and }s are. Then you will be able to see where the divisions of the class are; simply adding a } might not be the right way to sort out the problem.
Don't add {s and }s by hand whilst writing code. Let the IDE pair off the {} and let it put the cursor where you want to be.
 
Saloon Keeper
Posts: 9831
80
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Formatted by Eclipse
 
Campbell Ritchie
Marshal
Posts: 77157
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:Formatted by Eclipse. . . .

And that shows a discrepancy between lines 7 and 132. That tells me that there is something wrong, which includes the main method's being far too long. Don't write such long methods, least of all the main method.
 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, the do-loop ending at line 83 with this criterion: seems to be an infinite loop with no break statement
 
Campbell Ritchie
Marshal
Posts: 77157
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those multiply nested do loops are a recipe for confusion. Why aren't you using switch instead? The predicates for those do loops are incorrectly written; lines 64 and 131 should be simplified, for example.
Why have you got class names starting with small letters? Class names should start with Capital Letters. Why has the personaje class not got a constructor taking all the features in lines 20‑32? (Though a constructor with six parameters is difficult to use.)
Use one Scanner reading System.in.
Only use one‑letter names for formal type parameters or parameters with no meaning or loop variables. It is not obvious what a, x, y, and z mean.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic