Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By Tolls

Thread: Constructors

  1. #1
    cups is offline Member
    Join Date
    Dec 2011
    Posts
    14
    Rep Power
    0

    Default Constructors

    Hey there!

    I do understand what a Constructor does and I've used it before,
    but I was wondering: If I want to use a Constructor, I write a new Class and the class's name and the constructor's name have to be the same,
    is that right?
    So I can only have more than one Constructor in that class, if it has the same name as the first, but more or less arguments?!
    What else can I do with the class? Is it only there to build the constructor(s) in it? Because I think I cannot call another Method in it, right?
    I could build one, though, couldn't I? Would I?

    Would be great if someone would be able to explain,
    b/c I cannot find these questions in google.
    Everyone explains how to use one or build one, but I did this
    already and it worked fine.
    Now I wanna somehow find out more about it in theory.



    cups ;)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Constructors

    You want to read up on object oriented programming.
    Java is an OO language, so (most) everything it works with are objects, which are instances of a class. Those objects will have attributes and methods as defined by the class. The constructor is simply the part of the class that defines how and object of that class can be created.

    Here's the Oracle tutorial on it.
    arc535 likes this.

Similar Threads

  1. Need help with constructors
    By tpfaff in forum New To Java
    Replies: 10
    Last Post: 10-22-2010, 04:33 AM
  2. Constructors
    By suresh.sa in forum New To Java
    Replies: 5
    Last Post: 10-20-2010, 12:10 AM
  3. Constructors?
    By annna in forum New To Java
    Replies: 3
    Last Post: 01-27-2010, 10:51 PM
  4. Constructors
    By new2java2009 in forum New To Java
    Replies: 5
    Last Post: 08-18-2009, 06:46 AM
  5. constructors
    By khamuruddeen in forum New To Java
    Replies: 2
    Last Post: 12-01-2007, 03:15 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
  •