Hello,
I was wondering why do we need constructors with arguments?
Thank you
grisha83 26 Junior Poster in Training
Recommended Answers
Jump to Post> I was wondering why do we need constructors with arguments?
- Creation of an object based on an existing one [though this can be done the `Cloneable' way, constructor based approach is also pretty flexible]
- Creation of an object with known state [bind the ServerSocket to port XXX]
- Prevent creation …
Jump to PostIndeed, that's why I specifically mentioned a no-arg constructor[in case the class already has one] and not a default constructor. A default constructor is a no-arg constructor but the reverse doesn't make sense since if you explicitly define a no-arg constructor, there isn't anything *default* about it.
All 7 Replies
BestJewSinceJC 700 Posting Maven
grisha83 26 Junior Poster in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
verruckt24 commented: Full marks !!! Explains (concisely) everything. +4
BestJewSinceJC 700 Posting Maven
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.