I want to know, if a String
is a collection. I have read around but am still quite confused.
Strings are immutable objects representing a character sequence (CharSequence
is one of the interfaces implemented by String).
Main difference to char arrays and collections of chars: String cannot be modified, it's not possible (ignoring reflection) to add/remove/replace characters.
Internally they are represented by a char array with an offset and length (this allows to create lightweight substrings, using the same char arrays).
Example: ['F','o','o','H','e','l','l','o',' ','W','o','r','l','d'], offset=3, count=5 = "Hello"
.
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