The integral types in Java are all signed two's-complement integers. A byte ranges from -128 to 127 (8-bit); a short from -32768 to 32767 (16-bit); an int from -2147483648 to 2147483647 (32-bit); a long from
-9223372036854775808 to 9223372036854775807 (64-bit). All ranges are inclusive. The floating point types are all IEEE 754 floating point numbers. The char type is an integral type which ranges from 0 to 65535.

The biggest mistake in the Java programming language. Primitive types (such as long, int, short, byte, char and boolean) necessitate excessive overloading and duplicate code because they are not objects. The designers should have learned from Smalltalk that 'everything's an object' is a Good Thing and can be implemented efficiently, especially in a typed language like Java.

I do not think loki7 has much of a point. If you need objects, that's what the wrapper classes ar for - for each primitive type, there is a class that just wraps its value. Thus, no need for duplicate code or overloading.

Something else that sets the primitive types apart from objects is that they are passed by value, not by reference. This might be seen as both a feature (because quite often you want to pass something by value, and always having to use clone() is annoying), and a bug (because it introduces an inconsistency).

Finally, if even numbers were objects, you'd almost inevitably start having to overload or redefine operators (for what if you derived your own class from the number classes, changed it completely and still wanted to use normal arithmetic operators?), and that usually (IMO) results in a huge, ugly mess.

Log in or registerto write something here or to contact authors.