wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Card Game compilation issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Card Game compilation issue" Watch "Card Game compilation issue" New topic
Author

Card Game compilation issue

tyler jenkins
Greenhorn

Joined: Jul 25, 2013
Posts: 2
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
Sheriff

Joined: Sep 28, 2004
Posts: 18747
    
  40

tyler [surl='http://jenkins-ci.org/' class='api' title='Continuous Integration Engine wrote:jenkins[/surl]]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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
tyler jenkins
Greenhorn

Joined: Jul 25, 2013
Posts: 2
http://www.compileonline.com/compile_java_online.php
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
You put this line to class scope, that is, outside any method, where declarations belong and not statements like this:

Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7676
    
  19

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

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
C Sanders
Greenhorn

Joined: Jul 29, 2013
Posts: 2
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

Joined: May 22, 2012
Posts: 867
    
    5
C Sanders wrote:
Another issue is comparing to true should be all lowercase ('true' not 'True').


However instead of this:


rather use this:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Card Game compilation issue