Vous êtes sur la page 1sur 3

Downcasting and the runtime checks require extra time for the running program and extra effort

from the programmer. A parameterized type is a class that the compiler can automatically customize to work with particular types. For example, with a parameterized container, the compiler could customize that container so that it would accept only Shapes and fetch only Shapes.

Its worth noting that exception handling isnt an object-oriented feature, although in object-oriented languages the exception is normally represented by an object. Exception handling existed before objectoriented languages.

Where storage lives


Registers.

The stack. The Java system must know, while it is creating the program, the exact lifetime of all the items that are stored on the stack. This constraint places limits on the flexibility of your programs, so while some Java storage exists on the stackin particular, object referencesJava objects themselves are not placed on the stack.

The heap. This is a general-purpose pool of memory (also in the RAM area) where all Java objects live. Constant storage. Non-RAM storage. If data lives completely outside a program, it can exist while the program is not running, outside the control of the program. The two primary examples of this are streamed objects, in which objects are turned into streams of bytes, generally to be sent to another machine, and persistent objects, in which the objects are placed on disk so they will hold their state even when the program is terminated.

Primitive types:

High-precision numbers

Bitwise operators can be combined with the = sign to unite the operation and assignment: &=, |= and ^= are all legitimate. (Since ~ is a unary operator, it cannot be combined with the = sign.)

The boolean type is treated as a one-bit value, so it is somewhat different. You can perform a bitwise AND, OR, and XOR, but you cant perform a bitwise NOT (presumably to prevent confusion with the logical NOT).

For booleans, the bitwise operators have the same effect as the logical operators except that they do not short circuit.

Shift operators

Casting from a derived type to a base type moves up on the inheritance diagram, so its commonly referred to as upcasting. Upcasting is always safe because youre going from a more specific type to a more general type.

final data
It can be a compile-time constant that wont ever change.

2. It can be a value initialized at run time that you dont want changed.
In the case of a compile-time constant, the compiler is allowed to fold the constant value into any calculations in which its used; that is, the calculation can be performed at compile time, eliminating some run-time overhead.

Blank finals
Java allows the creation of blank finals, which are fields that are declared as final but are not given an initialization value.

final methods

Polymorphism:
separation of interface from implementation, to decouple what from how. to decouple what from how.

covariant return types, which means that an overridden method in a derived class can return a type derived from the type returned by the callbacks. With a callback, some other object is given a piece of information that allows it to call back into the originating object at some later point. base-class method:

A closure is a callable object that retains information from the scope in which it was created.

Vous aimerez peut-être aussi