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
JavaBot
JavaBot4d ago
This post has been reserved for your question.
Hey @SidKid! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st4d ago
use the String class provided by the JDK
ENDERFUN
ENDERFUN4d ago
To 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 need
dan1st
dan1st4d ago
even for socket stuff, String is sufficient in most cases
ENDERFUN
ENDERFUN4d ago
Yeah, 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)
dan1st
dan1st4d ago
you can (in principle) still use Strings without reading it line by line
ENDERFUN
ENDERFUN4d ago
I'd love to elaborate, but maybe somewhere else
ENDERFUN
ENDERFUN4d ago
Guess uumm #share-knowledge is for that right?
dan1st
dan1st4d ago
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
ENDERFUN
ENDERFUN4d ago
Done
JavaBot
JavaBot3d ago
💤 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.

Did you find this page helpful?