5
Conversions and Promotions
CONVERSIONS AND PROMOTIONS
A conversion from type
double
 to type
long
 requires a nontrivial translation
from a 64 bit floating point value to the 64 bit integer representation.
Depending on the actual run time value, information may be lost.
In every conversion context, only certain specific conversions are permitted.
The specific conversions that are possible in Java are grouped for convenience of
description into several broad categories:
Identity conversions
Widening primitive conversions
Narrowing primitive conversions
Widening reference conversions
Narrowing reference conversions
String conversions
There are five
conversion contexts
 in which conversion of Java expressions
may occur. Each context allows conversions in some of the categories named
above but not others. The term  conversion  is also used to describe the process of
choosing a specific conversion for such a context. For example, we say that an
expression that is an actual argument in a method invocation is subject to  method
invocation conversion,  meaning that a specific conversion will be implicitly cho 
sen for that expression according to the rules for the method invocation argument
context.
One conversion context is the operand of a numeric operator such as
+
 or
*
.
The conversion process for such operands is called
numeric promotion
. Promotion
is special in that, in the case of binary operators, the conversion chosen for one
operand may depend in part on the type of the other operand expression.
This chapter first describes the six categories of conversions ( 5.1), including
the special conversions to
String
 allowed for the string concatenation operator
+
.
Then the five conversion contexts are described:
Assignment conversion ( 5.2,  15.25) converts the type of an expression to
the type of a specified variable. The conversions permitted for assignment are
limited in such a way that assignment conversion never causes an exception.
Method invocation conversion ( 5.3,  15.8,  15.11) is applied to each argu 
ment in a method or constructor invocation and, except in one case, performs
the same conversions that assignment conversion does. Method invocation
conversion never causes an exception.
52






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