Non-object-oriented language basics, Part 1; Explore comments, identifiers, data types, literals, and variables

Although the preprocessor typically translates a single ASCII character into a single Unicode character, it can also render several ASCII characters as one Unicode character. This situation arises when the preprocessor encounters a Unicode escape sequence: a character sequence in the form \uxxxx, wh...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Veröffentlicht in:Java world 2000-12, p.1
1. Verfasser: Friesen, Geoff
Format: Magazinearticle
Sprache:eng
Schlagworte:
Online-Zugang:Volltext
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
Beschreibung
Zusammenfassung:Although the preprocessor typically translates a single ASCII character into a single Unicode character, it can also render several ASCII characters as one Unicode character. This situation arises when the preprocessor encounters a Unicode escape sequence: a character sequence in the form \uxxxx, where each x represents a hexadecimal digit. When the preprocessor encounters a Unicode escape sequence, it converts the sequence's six ASCII characters into a single Unicode character. For example, if the preprocessor finds \u20ac -- six ASCII characters that represent a single Unicode character denoting the euro, the European Union's currency symbol -- it would convert these six characters into a single Unicode character, and store the resulting 16-bit value in memory. As you read this article, you'll find out when Unicode character sequences can come in handy. A character data type describes the representation of character data items. The JVM represents a character data item as an unsigned 16-bit integer. There is no sign bit. Various operations can be performed on characters, but those operations first convert the unsigned 16-bit integer to an integer or long integer. When the operation is complete, special byte code instructions (generated by the compiler) convert the integer data item back to a character data item. char represents a character data type in source code. You must often convert a data item from one data type to another. If a narrower data item -- one with fewer bits -- must convert to a wider data type, which has more bits, the compiler uses a widening conversion rule to implicitly complete the conversion. The same applies for converting the data item from a byte/character/integer/ long integer/short integer data type to a double-precision floating- point or floating-point data type. However, when the compiler converts from a wider data type to a narrower data type -- or from a double-precision floating-point data type to a byte/character/ integer/long integer/short integer data type -- it implements a narrowing conversion rule that forces the developer to identify an explicit translation. The developer does that by specifying a cast operator, which I will discuss in my next article.
ISSN:1091-8906
1091-8906