Chapter 4: Making (Managed web hosting) the Most of Variables and
Chapter 4: Making the Most of Variables and Their Values 83 You can give variables their starting values in a declaration. In Listing 4-3 for instance, one declaration can replace several lines in the mainmethod (all but the calls to printand println). int weightOfAPerson = 150, elevatorWeightLimit = 1400, numberOfPeople = elevatorWeightLimit / weightOfAPerson; When you do this, you don t say that you re assigning values to variables. The pieces of the declarations with equal signs in them aren t really called assignment statements. Instead, you say that you re initializing the variables. Believe it or not, keeping this distinction in mind is helpful. Like everything else in life, initializing a variable has advantages and disadvantages: When you combine six lines of Listing 4-3 into just one declaration, the code becomes more concise. Sometimes, concise code is easier to read. Sometimes it s not. As a programmer, it s your judgment call. By initializing a variable, you may automatically avoid certain programming errors. For an example, see Chapter 7. In some situations, you have no choice. The nature of your code forces you either to initialize or not to initialize. For an example that doesn t lend itself to variable initialization, see the deleting-evidence program in Chapter 6. The Atoms: Java s Primitive Types The words int and double, which I describe in the previous sections, are examples of primitive types (also known as simple types) in Java. The Java language has exactly eight primitive types. As a newcomer to Java, you can pretty much ignore all but four of these types. (As programming languages go, Java is nice and compact that way.) The complete list of primitive types is shown in Table 4-1. Table 4-1 Java s Primitive Types Type Name What a Literal Looks Like Range of Values Whole number types byte (byte)42 128 to 127 short (short)42 32768 to 32767 (continued)
Have you tried other web hosting companies and found out that their focus and your focus are in clash?Check our filemaker web hosting services.