EXPRESSIONS
String Concatenation Operator
+
15.17.1
15.17   Additive Operators
The operators
+
 and
 are called the
additive operators
. They have the same pre 
cedence and are syntactically left associative (they group left to right).
AdditiveExpression:
MultiplicativeExpression
AdditiveExpression
 +
MultiplicativeExpression
AdditiveExpression
  
MultiplicativeExpression
If the type of either operand of a + operator is
String
, then the operation is
string concatenation.
Otherwise, the type of each of the operands of the
+
 operator must be a primi 
tive numeric type, or a compile time error occurs.
In every case, the type of each of the operands of the binary
 operator must
be a primitive numeric type, or a compile time error occurs.
15.17.1   String Concatenation Operator
+
If only one operand expression is of type
String
, then string conversion is per 
formed on the other operand to produce a string at run time. The result is a refer 
ence to a newly created
String
 object that is the concatenation of the two
operand strings. The characters of the left hand operand precede the characters of
the right hand operand in the newly created string.
15.17.1.1
String Conversion
Any type may be converted to type
String
 by
string conversion
.
A value
x
 of primitive type
T
 is first converted to a reference value as if by
giving it as an argument to an appropriate class instance creation expression:
If
T
 is
boolean
, then use
new Boolean(x)
 ( 20.4).
If
T
 is
char
, then use
new Character(x)
 ( 20.5).
If
T
 is
byte
,
short
, or
int
, then use
new Integer(x)
 ( 20.7).
If
T
 is
long
, then use
new Long(x)
 ( 20.8).
If
T
 is
float
, then use
new Float(x)
 ( 20.9).
If
T
 is
double
, then use
new Double(x)
 ( 20.10).
This reference value is then converted to type
String
 by string conversion.
355






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