This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "constructor" Watch "constructor" New topic
Author

constructor

charishma gottumukkula
Greenhorn

Joined: Nov 06, 2006
Posts: 20
Can we have parameterized constructor in java ?
Eric Daly
Ranch Hand

Joined: Jul 11, 2006
Posts: 143
absolutely
read up on sun's java tutorial
you could start on this page and follow the "trail" to learn more about constructors with different parameter lists
http://java.sun.com/docs/books/tutorial/java/javaOO/constructors.html


Studying for SCJP 6
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18914
    
  40

Originally posted by charishma gottumukkula:
Can we have parameterized constructor in java ?


If you mean parameters to the constructor, then as Eric pointed out, the answer is obviously yes.

However, when you say "parameterized", do you mean parameterized types? Like so...



The answer is yes. Java supports generics with constructors -- just like the support for generic methods.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
Consider Paul's rocket mass heater.
 
subject: constructor