Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,367
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Otakon View Post
    I thought THAT was the constructor.

    This is driving me nuts...
    It isn't; beware of those nice people with their white coats and syringes. btw, you should study the basics of the Java language some more before you attempt to code anything at all.

    kind regards,

    Jos

  2. #22
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    No. A constructor is a special part of each class which shares the same name as a class:
    Java Code:
    public class MyClass{
        //Constructor
        public MyClass(){
            //do stuff in constructor
        }
    }
    What you have is a main method, which is a method used to run a program, and your program generally only has one of those.

    Every class in your program will have a constructor though. The constructor is where class variables can be initialized, and parameters can be passed into the class from elsewhere on instantiation.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  2. Replies: 2
    Last Post: 10-08-2009, 11:28 PM
  3. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. Roll 2-Dice "Pig" Game Help
    By King8654 in forum AWT / Swing
    Replies: 7
    Last Post: 04-07-2008, 06:58 PM

Posting Permissions

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