Results 1 to 2 of 2
Thread: Constructors
- 02-15-2012, 11:46 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 14
- Rep Power
- 0
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 ;)
- 02-15-2012, 11:55 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,451
- Rep Power
- 16
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.
Similar Threads
-
Need help with constructors
By tpfaff in forum New To JavaReplies: 10Last Post: 10-22-2010, 04:33 AM -
Constructors
By suresh.sa in forum New To JavaReplies: 5Last Post: 10-20-2010, 12:10 AM -
Constructors?
By annna in forum New To JavaReplies: 3Last Post: 01-27-2010, 10:51 PM -
Constructors
By new2java2009 in forum New To JavaReplies: 5Last Post: 08-18-2009, 06:46 AM -
constructors
By khamuruddeen in forum New To JavaReplies: 2Last Post: 12-01-2007, 03:15 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks