java question about strings
is it better to work in Java with strings using library that allows operations on Strings or it is better work with strings as an array of chars (so subsequently use operations where treat the string as an array of chars)
12 Replies
⌛
This post has been reserved for your question.
Hey @SidKid! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
use the
String
class provided by the JDKTo elaborate a bit: The answer is: depends. In 98% of situations you'd want to just use
String
, but there are some rare occasions where String
just won't cut it (f. ex. socket programming, which I've been fighting with for 2 weeks or JNI). But unless you'd want to do something stupid with Java, String
class is all you would ever needeven for socket stuff,
String
is sufficient in most casesYeah, in most cases sure. The only instance when it's straight up wrong is when you want to parse http request with binary body and you need to find
\r\n\r\n
(speaking from experience)you can (in principle) still use
String
s without reading it line by lineI'd love to elaborate, but maybe somewhere else
Guess uumm #share-knowledge is for that right?
if you want to write somethig that's likely useful for others in the future, create a thread in #general and ping a staff member
Done
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.