15.2
Variables as Values
EXPRESSIONS
declared
void
 ( 8.4). Such an expression can be used only as an expression state 
ment ( 14.7), because every other context in which an expression can appear
requires the expression to denote something. An expression statement that is a
method invocation may also invoke a method that produces a result; in this case
the value returned by the method is quietly discarded.
Each expression occurs in the declaration of some (class or interface) type
that is being declared: in a field initializer, in a static initializer, in a constructor
declaration, or in the code for a method.
15.2   Variables as Values
If an expression denotes a variable, and a value is required for use in further eval 
uation, then the value of that variable is used. In this context, if the expression
denotes a variable or a value, we may speak simply of the
value
 of the expression.
15.3   Type of an Expression
If an expression denotes a variable or a value, then the expression has a type
known at compile time. The rules for determining the type of an expression are
explained separately below for each kind of expression.
The value of an expression is always assignment compatible ( 5.2) with the
type of the expression, just as the value stored in a variable is always compatible
with the type of the variable. In other words, the value of an expression whose
type is
T
 is always suitable for assignment to a variable of type
T
.
Note that an expression whose type is a class type
F
 that is declared
final
 is
guaranteed to have a value that is either a null reference or an object whose class
is
F
 itself, because
final
 types have no subclasses.
15.4   Expressions and Run Time Checks
If the type of an expression is a primitive type, then the value of the expression is
of that same primitive type. But if the type of an expression is a reference type,
then the class of the referenced object, or even whether the value is a reference to
an object rather than
null
, is not necessarily known at compile time. There are a
few places in the Java language where the actual class of a referenced object
affects program execution in a manner that cannot be deduced from the type of the
expression. They are as follows:
302






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved