Photoshop web design - Chapter 2 Introduction to Java Applications 95

Chapter 2 Introduction to Java Applications 95 A variable is a location in the computer s memory where a value can be stored for use by a program. The name of a variable is any valid identifier. All variables must be declared with a name and a data type before they can be used in a program. Declarations end with a semicolon (;) and can be split over several lines, with each variable in the declaration separated by a comma (forming a comma-separated list of variable names). Variables of type inthold integer values (whole numbers such as 7, 11, 0 and 31,914). Types such as int, float, doubleand char are primitive data types. Names of primitive data types are keywords of the Java programming language. A prompt directs the user to take a specific action. A variable is assigned a value by using an assignment statement, which uses the assignment operator, =. The =operator is called a binary operator, because it has two operands. Method Integer.parseInt(a static method of class Integer) converts its String argument to an intvalue. Java has a version of the + operator for string concatenation that enables a string and a value of another data type (including another string) to be concatenated. Every variable has a name, a type, a size and a value. When a value is placed in a memory location, the value replaces the value previously in that location. When a value is read out of a memory location, the variable s value remains unchanged. The arithmetic operators are binary operators, because they operate on two operands. Integer division yields an integer result. Arithmetic expressions in Java must be written in straight-line form to facilitate entering programs into the computer. Operators in arithmetic expressions are applied in a precise sequence determined by the rules of operator precedence. Parentheses may be used to force the order of evaluation of operators. When we say that operators are applied from left to right, we are referring to the associativity of the operators. Some operators associate from right to left. Java s ifstructure allows a program to make a decision based on the truth or falsity of a condition. If the condition is met (i.e., the condition is true), the statement in the body of the if structure executes. If the condition is not met (i.e., the condition is false), the body statement does not execute. Conditions in if structures can be formed by using the equality operators and relational operators. The empty string is a string containing no characters. Every variable declared in a method must be initialized before it can be used in an expression. TERMINOLOGY addition operator (+) body of a class definition applet body of a method definition application braces ({ and }) argument to a method case sensitive arithmetic operators character string assignment operator (=) class assignment statement class definition associativity of operators .class file extension backslash () escape character class keyword binary operator class name Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services

Leave a Reply