Strings and Characters

Python Java
String literals are formed using either the single quotes or the double quotes as delimiters.

Strings are instances of the str class.  Strings are immutable objects.

Character literals are simply strings that contain a single character.

An escape sequence is formed using the ‘\’ character followed by an appropriate letter such as ‘n’ or ‘t’.

String literals are formed using the double quotes as delimiters.

Strings are instances of the Stringclass.  Strings are immutable objects.

Character literals are formed using the single quotes as delimiters.

Characters are values of the chardata type.  This type uses  2 bytes to represent the Unicode set.

An escape sequence, either as a character or as a string, is formed using the ‘\’ character followed by an appropriate letter such as ‘n’ or ‘t’.

© Ken Lambert. All rights reserved.