• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Errors

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've written a code:

and I have 3 errors:
1. Syntax error, insert ")" to complete Classbody
2. Syntax error on token ""Java", delete this token
3. Syntax error on token ")", delete this token

What should I do?
 
Master Rancher
Posts: 4509
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What java version are you using to compile that code?
I get a different error message when I compile it using several different versions of java:
 
Kali Hackman
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Java 11
 
Bartender
Posts: 4691
183
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
system must start with a capital s, so System.out....
 
Norm Radder
Master Rancher
Posts: 4509
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

system.out println("Java");


My compiler when looking at that statement sees a return value, a method name and arguments to to the method.

The syntax for coding a method's declaration:
<Return value> <method name> ( <args to method>)

Look at some working code for how to correctly call the println method.  That statement is used in many programs.
 
Rancher
Posts: 184
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://en.wikipedia.org/wiki/%22Hello,_World!%22_program
It also contains an example for Java.
Or is this a more complicated question and just don't get it?
 
Marshal
Posts: 74381
334
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apart from the spelling error which Piet noticed, the real problem is that you are trying to write a statement “naked” in the method body. Statements are only permitted in methods, constructors, and initialsers. The nearest to a statement you can have “naked” in the class is a declaration and initialisation.
 
Norm Radder
Master Rancher
Posts: 4509
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Besides the spelling error (lowercase s) there is a dot missing between out and println.
That is why my compiler sees that statement as an attempt at a method declaration.
 
Campbell Ritchie
Marshal
Posts: 74381
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I missed the missing dot; sorry. A miss is as good as a mile.
 
Piet Souris
Bartender
Posts: 4691
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And I missed Norms and Campbells remark.  
 
Saloon Keeper
Posts: 1652
61
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kali:

If someone already asked this I apologize for missing it, but what is your primary source from which you are trying to learn Java?

There are too many introductions to Java to possibly count, even a very large number of free sources.

But it would likely be a good idea to follow *something*.  The Javadocs are very good to consult when coding, but are not intended as a tutorial for those new to Java.

Of the free sources, perhaps this one originally from Sun and updated by Oracle thru Java 8 (but not further) would be hard to go very wrong with:
https://docs.oracle.com/javase/tutorial/java/index.html

There are a tremendous amount of alternatives, all with their own advantages and disadvantages, some of which are a matter of taste.

People enjoy giving opinions here and helping you when you are stuck with something that you tried to read about and didn't understand, but I believe it would be helpful to be following a tutorial aimed at those new to Java at this point.  Many people here will be happy to answer any questions that come up for you during such a process.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kali Hackman wrote:I've written a code:

and I have 3 errors:
1. Syntax error, insert ")" to complete Classbody
2. Syntax error on token ""Java", delete this token
3. Syntax error on token ")", delete this token

What should I do?



Bro you missing a dot, got capitalization errors, and your stack trace is bunk.


 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic