Strings Overview


In some languages, strings are null-terminated arrays of characters and there is no separate class for strings. In generic, strings are represented by the class string. Thus, strings are reference types.

String literals are actually string objects. For example, in the program

// string_a - introduction to strings

generic string_a
{
    string_a()
    {
     s = "hello world"
     s.println()
    }
}

the literal "hello world" causes the construction of a string object.

Strings are Immutable

Strings are immutable, which is to say, that they cannot be changed after they have been created. To implement changes, new strings can be created from existing strings and unused strings are automatically garbage collected.

A string is a reference object, so a string reference may be changed to refer to another string. However, the contents of any individual string cannot be changed.