Results 1 to 5 of 5
  1. #1
    jerryrice80 is offline Member
    Join Date
    Sep 2009
    Posts
    1
    Rep Power
    0

    Default Where do I put main method?

    Fixed everything. thanks
    Last edited by jerryrice80; 09-17-2009 at 05:10 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Technically you can put it anywhere. Conventionally,it depends on what is going to be done in that main method. e.g If it's going to test your Car class then you can put it either in the Car class or in a separate class called CarTest. The preferred method is a separate class called CarTest.

  3. #3
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    The main can be put anywhere inside of a class that any other method can be. I typically put it at the very bottom of the class just before the closing "}"
    My Hobby Project: LegacyClone

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Count your braces { and } must match.
    If you indent your code properly it will be obvious where the problem is.

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You are putting the method inside a constructor. Not good. Don't try to guess and use trial and error for these things. Rather get Sun's Java tutorial and read it.

Similar Threads

  1. Main method here to :S:S hlp pls
    By eliCanzee in forum AWT / Swing
    Replies: 6
    Last Post: 05-27-2009, 05:45 AM
  2. Help me for main method
    By eliCanzee in forum AWT / Swing
    Replies: 1
    Last Post: 05-26-2009, 01:43 PM
  3. Private main method
    By bugger in forum New To Java
    Replies: 1
    Last Post: 12-21-2007, 10:45 AM
  4. main method
    By eva in forum New To Java
    Replies: 5
    Last Post: 12-19-2007, 10:25 AM
  5. The main method in java...
    By lenny in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 07:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •