Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class/interface/enum errors

 
Reno Madrigal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i have about 30 of these errors and thats just awful, someday my teacher will slow down and actually teach us proper syntax until then I would appreciate some advise.



Here are my errors:

class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
class, interface, or enum expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
illegal start of type
class, interface, or enum expected
[ October 05, 2007: Message edited by: Reno Madrigal ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The line

}//END Primaries2008()

is a proximal cause of many of your errors -- you're closing the class body here, and so all the code afterwards appears outside of any class. This is why the compiler says it's looking for a class, interface, or enum -- your methods are appearing at the top level of the file.

Once you fix that, you've got a misplaced semicolon here:

public void beginPrimary();

Then later in the file, I start to see methods ending prematurely, leaving some statements outside any method body and such.

Here's a hint: never, ever write more than a dozen lines of code without compiling it. Write a few lines, get it to compile. Add some more, get *that* to compile. Build up your programs a piece at a time. That way if you get an error, you know it's due to the last small changes you made.

No one except beginning students tries to write code by typing it all in, then compiling it and watching a million errors pile up!

If I were you, I'd set this file off to the side and start over. First get this to compile:

public class Primaries2008 {
}

Then add an empty method, like



And make sure that compiles before you start to add code to the function. Whenever you add a few lines, compile it, run it if possible, and see if what happens matches what you expect. Add extra code (print statements, for example) just for testing purposes. Make sure you understand each line as it runs.
 
Jinny Morris
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reno -

Also, it looks like you're trying to use AND and OR as operators; as far as I know, those keywords don't exist in Java. You need to use && and || for the Boolean and and or operators.

Even if it hasn't been assigned, you might check your textbook for things like operators and control constructs - they're probably explained in the text.

Nice to know where all the election results questions are coming from!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic