4
Types, Values, and Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . .  29
4.1
The Kinds of Types and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2
Primitive Types and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2.1
Integral Types and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2.2
Integer Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2.3
Floating Point Types and Values. . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2.4
Floating Point Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.5
The
boolean
 Type and
boolean
 Values. . . . . . . . . . . . . . . . . . . . 36
4.3
Reference Types and Values  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3.1
Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.3.2
The Class
Object
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.3.3
The Class
String
 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.3.4
When Reference Types Are the Same. . . . . . . . . . . . . . . . . . . . . . 42
4.4
Where Types Are Used  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.5
Variables  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.5.1
Variables of Primitive Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.5.2
Variables of Reference Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.5.3
Kinds of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.5.4
Initial Values of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.5.5
Variables Have Types, Objects Have Classes . . . . . . . . . . . . . . . . 47
5
Conversions and Promotions  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  51
5.1
Kinds of Conversion  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.1.1
Identity Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.1.2
Widening Primitive Conversions. . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.1.3
Narrowing Primitive Conversions . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.1.4
Widening Reference Conversions . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.1.5
Narrowing Reference Conversions . . . . . . . . . . . . . . . . . . . . . . . . 59
5.1.6
String Conversions  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.1.7
Forbidden Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.2
Assignment Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.3
Method Invocation Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.4
String Conversion  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.5
Casting Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.6
Numeric Promotions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.6.1
Unary Numeric Promotion  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.6.2
Binary Numeric Promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6
Names  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  77
6.1
Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.2
Names and Identifiers  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.3
Scope of a Simple Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.3.1
Hiding Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.4
Members and Inheritance  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.4.1
The Members of a Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.4.2
The Members of a Class Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
viii






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