Understanding 'error: '.class' expected'
Error Description:
This error occurs during compilation when the compiler encounters a type name in a context where it expects an expression. This error message indicates that the compiler is confused and believes a .class expression is required at that location.
Causes:
Fixes:
The solution depends on the intended code:
double d = 1.9; int i = (int) d; // Correct: cast 1.9 to integer
int j = someFunction(a); // Correct ... assuming 'a' is appropriate
Additional Examples:
someMethod(array[]);
int i = someMethod(int j); // Should be: int i = someMethod(j);
int i = int(2.0); // Should be: int i = (int) 2.0;
int[]; letterCount = new int[26];
if (someArray[] > 80) { // Should be: if (someArray[someIndex] > 80)
if ((withdraw % 5 == 0) && (acnt_balc >= withdraw + 0.50)) double cur = acnt_balc - (withdraw + 0.50); System.out.println(cur); else System.out.println(acnt_balc);
The above is the detailed content of Why Am I Getting the 'error: '.class' expected' Compilation Error in Java?. For more information, please follow other related articles on the PHP Chinese website!