• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Card Game compilation issue

 
tyler jenkins
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep getting an issue saying that I'm missing a [ or ; at the same line. It's been a while since I've programmed in Java but I keep looking over what I have and nothing seems to stand out. :3

 
Henry Wong
author
Marshal
Pie
Posts: 21518
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tyler jenkins wrote:I keep getting an issue saying that I'm missing a [ or ; at the same line. It's been a while since I've programmed in Java but I keep looking over what I have and nothing seems to stand out. :3


Well, compile errors come with a filename, line numbers, etc. It would be a good idea to start there -- and probably a good idea to point out the location for us...

Also, compile errors about missing stuff, are generally syntax errors -- and it may be a good idea to look at lines before the location pointed out by the compiler too.

Henry
 
tyler jenkins
Greenhorn
Posts: 2
 
Ivan Jozsef Balazs
Rancher
Posts: 982
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You put this line to class scope, that is, outside any method, where declarations belong and not statements like this:

 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tyler wrote:I keep looking over what I have and nothing seems to stand out...

tyler,

Please DontWriteLongLines. It makes your thread very hard to read. I've broken yours up this time, but for future reference, please remember:
80 characters max.
And that includes comments (which I notice you were careful about) AND string literals.

Thanks.

Winston
 
C Sanders
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed that you used a boolean variable that you named switch. switch is a keyword. Please use a different variable name for that boolean value.
Also, you are comparing an int to the value 'y'. This will probably not yield the result you are expecting.
Another issue is comparing to true should be all lowercase ('true' not 'True').


As Ivan Jozsef Balazs pointed out, you could (some may argue that you should/must) use


The point that I am trying to make is that there are Java keywords that you need to be aware of ('switch' is one. 'true' is another). If you are trying to see "if" something is true, you don't need to explicitly use the word true in the comparison. If you do explicitly use the keyword 'true', it must be all lowercase. You are allowed to use a variable named 'True', but it is not conventional and is not the same as 'true'.
 
Ivan Jozsef Balazs
Rancher
Posts: 982
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C Sanders wrote:
Another issue is comparing to true should be all lowercase ('true' not 'True').


However instead of this:


rather use this:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic