Troubleshooting

Floating-Point Literal Loss of Precision Error

The compiler reports as error stating that your assignment of a floating-point literal to a variable of type float might result in a loss of precision.

When you assign a floating-point literal to a float variable, you must explicitly specify the type suffix. When you omit the suffix, the compiler assumes that the literal is of type double, which cannot be assigned to a float without an explicit cast. The following two statements illustrate a correct and an incorrect assignment statement:

float myFirstFloat = 1.0;   // compiler error
float mySecondFloat = 2.0F; // correct

ArrayIndexOutOfBoundsException

An ArrayIndexOutOfBoundsException occurs at runtime when you attempt to access ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.