Chapter 4: Making the Most of Variables and (Web proxy server)
Chapter 4: Making the Most of Variables and Their Values 85 Figure 4-5: An exciting run of the program of Listing 4-4. In Listing 4-4, the first initialization stores the letter b in the variable myLittleChar. In the initialization, notice how b is surrounded by single quote marks. In Java, every charliteral starts and ends with a single quote mark. In a Java program, single quote marks surround the letter in a charliteral. If you need help sorting out the terms assignment, declaration, and initialization, see the Combining Declarations and Initializing Variables section, earlier in this chapter. In the second initialization of Listing 4-4, the program calls an API method whose name is Character.toUpperCase. The Character.toUpperCase method does just what its name suggests the method produces the uppercase equivalent of the letter b. This uppercase equivalent (the letter B) is assigned to the myBigCharvariable, and the B that s in myBigCharis printed on the screen. For an introduction to the Java Application Programming Interface (API), see Chapter 3. If you re tempted to write the following statement, char myLittleChars = barry ; //Don t do this please resist the temptation. You can t store more than one letter at a time in a charvariable, and you can t put more than one letter between a pair of single quotes. If you re trying to store words or sentences (not just single letters), you need to use something called a String. For a look at Java s Stringtype, see the section, The Molecules and Compounds: Reference Types, later in this chapter. If you re used to writing programs in other languages, you may be aware of something called ASCII Character Encoding. Most languages use ASCII; Java uses Unicode. In the old ASCII representation, each character takes up only 8 bits, but in Unicode, each character takes up 8, 16, or 32 bits. Whereas ASCII stores the letters of the familiar Roman (English) alphabet, Unicode has room for characters from most of the world s commonly spoken languages. The
The UK economy was the first in the world to enter the Industrial Revolution, and initially concentrated on heavy industry such as shipbuilding, coal mining, steel production and textiles.All our UK Web Hosting plans are very cheap and they fully support PHP mysql Dreamweaver frontpage and much more.