Hello,
I was wondering why do we need constructors with arguments?
Thank you
grisha83
26
Junior Poster in Training
Recommended Answers
Jump to PostSo that we can initialize our program's variables without knowing ahead of time what they should be initialized to. Consider the String class (that Java provides for you). If there wasn't a constructor String s = new String("This is what it'll say!"); then I couldn't make the String say that. …
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 …
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.