java note 1

Data Type

There are eight primitive types in Java. Four of them are integer types; two are floating- point number types; one is the character type char , used for code units in the Unicode encoding scheme。


Note: Big Numbers

Java has an arbitrary-precision arithmetic package. However, “big numbers,” as they are called, are Java objects and not a new Java type. We will see how to use them later in this chapter.


The boolean type has two values, false and true .In C++, The value 0 is equivalent to the bool value false , and a non-zero value is equivalent to true . This is not the case in Java.


Constant

In C++, we use const to denote a constant. In Java, you use the keyword final. The keyword final indicates that you can assign to the variable once, and then its value is set once and for all. It is popular to name constants in all uppercase.


Operators

“>>” and “<<” operators shift a bit pattern to the right or left. a >>> operator fills the top bits with zero, unlike >> which extends the sign bit into the top bits. There is no <<< operator.


Conversions between Numeric Types

It is often necessary to convert from one numeric type to another. Here shows the
legal conversions.