Hassaan
05/02/2024, 2:13 PMSam
05/02/2024, 2:23 PMStringBuilder
. It doesn't come up very often.CLOVIS
05/02/2024, 2:23 PMString
is a specific implementation in memory, in which all chars are stored consecutively in memory. CharSequence
, however, does not give any requirements with regards to storage, so you could construct a CharSequence from an input stream, etc.
However, CharSequence
instances are unsafe for comparison, so it's unsafe to put as a key in a map, etc, so it's quite limited.Hassaan
05/02/2024, 2:44 PMCLOVIS
05/02/2024, 3:00 PMCLOVIS
05/02/2024, 3:00 PMKlitos Kyriacou
05/02/2024, 3:02 PMget(index)
method with the implication that repeated calls to get(n)
will retrieve the same character, so it can't be used to stream data from an InputStream unless you cache every character read so far.CLOVIS
05/02/2024, 3:03 PM