How do strings work? In C we must declare the size of a char array to represent a "string".
But in java we do not allocate memory for the size of a string. So how does the string work?
Is there a pre deterimed size assigned to strings from the compiler or what?
coding101
0
Junior Poster in Training
Recommended Answers
Jump to PostThe String class handles all that. There must be a similar class in C++
Jump to PostThe class handles all those details. Remember that Strings are immutable. They know how much space they need when they are created.
Jump to Posthe asked how Strings work, not what you can do with a String.
since a better alternative was already provided, I didn't felt compelled to try and outdo the ones already posted earlier.My mistake, didn't saw the links above.
All 12 Replies
NormR1
563
Posting Sage
Team Colleague
coding101
0
Junior Poster in Training
NormR1
563
Posting Sage
Team Colleague
nHulk
-5
Light Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Trentacle
112
Junior Poster in Training
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
dheaven
12
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
dheaven
12
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
dheaven
12
Newbie Poster
stultuske
commented:
no harm by making a mistake, if you are prepared to be corrected :)
+12
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.