I just want to read it as its own "String" but a view is fine -- I don't need it to be materialized as a separate object. I'd prefer to not incur the overhead of creating a new object.
You can access the characters one by one with the charAt() method. If you already have a character array allocated, you could copy the characters into it, and use that. Neither of these would involve creating any more objects. But that's about it.
Note that if you call substring(), the String class doesn't copy the underlying char[] -- it only creates the new String object itself, and they share the char[].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With