Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1066
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: New to java, Help please ;)? |
| Date | 2011-09-19 16:12 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <11446343.1337.1316473979676.JavaMail.geo-discussion-forums@prfz40> (permalink) |
| References | <e26809e5-3b23-414d-80fa-4bfd9e5e998f@t3g2000vbe.googlegroups.com> <j58e9i$gij$1@dont-email.me> |
markspace wrote:
> Andre Ramseier wrote:
>> public class Main
>> {
>> public static void main (String [] args);
> ^^^
>> }
>> }
>>
>> Getting error when compiling:
>> <Identifier> not expected at code: System.out.println ("Please enter
>> your score: ");
>
> The version you posted is missing an open brace where I've indicated above.
That would be instead of the semicolon at the end of the 'public static void main' line.
'main' is a method (what some other languages might call a "function"). A method definition begins with an optional access specifier, 'public' here. Then it has an optional 'static'. Then the return type, 'void'. Then the name of the method, 'main', followed by parentheses containing arguments, if any.
After the closing parentheses you need a method body surrounded by curly braces, "{" and "}".
Put it all together:
public static void main(String [] args ) {
// method body here
}
This is covered in the Java tutorials:
<http://download.oracle.com/javase/tutorial/>
and for this question particularly,
<http://download.oracle.com/javase/tutorial/java/javaOO/methods.html>
--
Lew
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
New to java, Help please ;)? Andre Ramseier <andreramseier@gmail.com> - 2011-09-19 13:56 -0700
Re: New to java, Help please ;)? markspace <-@.> - 2011-09-19 15:04 -0700
Re: New to java, Help please ;)? Lew <lewbloch@gmail.com> - 2011-09-19 16:12 -0700
Re: New to java, Help please ;)? Roedy Green <see_website@mindprod.com.invalid> - 2011-09-20 15:03 -0700
csiph-web