The Artima Developer Community
Sponsored Link

Java Answers Forum
java

5 replies on 1 page. Most recent reply: Jul 3, 2008 4:53 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
n veerendra

Posts: 4
Nickname: veerendran
Registered: Jun, 2008

java Posted: Jun 29, 2008 7:42 AM
Reply to this message Reply
Advertisement
why constructor does not contain any return type?explain with one example


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: java Posted: Jul 2, 2008 12:24 AM
Reply to this message Reply
simple as it is: The constructor allways creates a instance of the class it's the constructor of. No need to specify anything.

Would not make sense if you would try to construct a Rectangle and get a String as return.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: java Posted: Jul 2, 2008 12:27 AM
Reply to this message Reply
hmmm, now I did your homework twice. Should stop doing that.

At least for this last question the answer was kinda obvious if you would have thought bout it.

Stephen Morrow

Posts: 5
Nickname: yawmark
Registered: Jan, 2007

Re: java Posted: Jul 2, 2008 10:45 AM
Reply to this message Reply
> simple as it is: The constructor allways creates a
> instance of the class it's the constructor of.

Maybe a bit nitpicky, but the constructor doesn't create an instance of the class. The constructor execution comes late in the process, as described in the Java Language Specification.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: java Posted: Jul 3, 2008 4:49 AM
Reply to this message Reply
right :)

Should have said probably you call the constructor to create a instance :)

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: java Posted: Jul 3, 2008 4:53 AM
Reply to this message Reply
... and not even that would have been right.
ah well

Flat View: This topic has 5 replies on 1 page
Topic: how to insert symbols Previous Topic   Next Topic Topic: tic -tac-toe

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use