Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: A Java Error

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default A Java Error

    Hi guys, i have the following error:

    Fortune.java:3: '(' expected
    public static void main [String () args ]
    ^

    I cant seem to put this in words, as in what the error means. I know what is wrong with the code but any help on how to word it to explain what is wrong and how.

    Regards

    Shyam


  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A Java Error

    Quote Originally Posted by Shyamz1 View Post
    Hi guys, i have the following error:

    Fortune.java:3: '(' expected
    public static void main [String () args ]
    ^

    I cant seem to put this in words, as in what the error means. I know what is wrong with the code but any help on how to word it to explain what is wrong and how.

    Regards

    Shyam
    Hi Shyamz.
    According to your compiler your missing a '('
    By the looks of it you have used '[' instead of the required '('

    public static void main [String () args ]

    Should look like:

    public static void main(String[] args)
    Last edited by Tempest; October 5th, 2010 at 09:56 AM.

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A Java Error

    Yeah i know what the problem is, but i have to log all my mistakes in a book, and dont have a clue what to write. I cant just write missed out a square bracket etc. I want something more so i can say i've understood it. Something like this: the computer thinks that the ( is part of the string literal or something like that.

    Any help?

    Regards

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A Java Error

    Sorry for not reading the entire post.

    I hope this will help you:

    Parentheses are used for surrounding parameter lists. Brackets, also known as square brackets, look like this [ ]. Java uses them for surrounding indexes for arrays.

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A Java Error

    ARe you this is correct... Thanks by the way.

  6. #6
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: A Java Error

    Yes, Tempest is right.

  7. #7
    Junior Member
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A Java Error

    Hi again, What would this error mean then.

    Fortune.java:3: invalid method declaration; return type required
    public static void main[String () args ]
    ^

    Regards

    Shyam

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: A Java Error

    It means you have confused the compiler.
    Swap your usage of [] and () and try it again.

    Did you read any of the previous posts about the correct syntax for a method definition?

  9. #9
    Junior Member
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A Java Error

    No you dont understand what i'm saying. The thing is i have to log all my errors and stuff, but i dont know what to write for this specific error. Understand? So what would i write about this error and what it means etc.

    Regards

    Shyam

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: A Java Error

    The problem with the code is a syntax error. Read the Language specifications to get the words you need.

Similar Threads

  1. Replies: 3
    Last Post: April 26th, 2011, 02:51 AM
  2. java Final Project Error
    By JavaStudent_09 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: August 21st, 2010, 09:23 PM
  3. Java Thread error plz help me
    By ani1125ster in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 12th, 2010, 10:07 AM
  4. Java error
    By d7o0om in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 12th, 2010, 08:14 AM
  5. java.lang.numberformatexception error
    By natalie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 19th, 2010, 04:16 AM