';' expected | Java needs a symbol here that is missing, most often the ; at the end of a statement. | Check the end of the line just before the mark and add the missing symbol. |
cannot find symbol | You used a name the compiler does not know: it was never declared, or it is spelled differently. | Declare the variable before using it, and match upper and lower case exactly. |
cannot find symbol (method) | You called a method that does not exist with this name or these arguments. | Check the method name and its arguments, for example println, not printn. |
cannot find symbol (class) | This class is unknown; usually an import line is missing. | Add the import, for example import java.util.Scanner;. |
incompatible types | The value does not fit the variable, such as text in an int or a double in an int. | Change the variable type or convert the value, such as (int) 3.5 or Integer.parseInt("19"). |
not a statement | This expression does nothing on its own, such as x + 1;. | Store or print the result, such as x = x + 1;. |
unclosed string literal | A " was opened and not closed on the same line. | Add the missing quotation mark. |
unclosed comment | A /* comment was never closed, so the rest of the file became a comment. | Add */ at the end of the comment. |
reached end of file while parsing | The file ended before every brace closed, so a } is missing. | Count the braces. In NetBeans, Alt+Shift+F formats the code and makes this visible. |
illegal start of expression | Something here cannot begin an expression, often because of a missing brace before it. | Check the braces and the line before the mark. |
illegal start of type | Code is somewhere it is not allowed, often outside main or after an extra brace. | Keep your statements inside the braces of main. |
variable x might not have been initialized | You read a variable that may not hold a value yet. | Give it a value when you declare it, such as int x = 0;. |
variable x is already defined | The same name is declared twice in the same scope. | To assign instead, drop the type on the second line: x = 5;. |
missing return statement | The method can finish without returning a value, although it is not void. | Make sure every path through the method ends in a return. |
incomparable types | These two types cannot be compared. | Convert one value, or compare strings with equals. |
bad operand types for binary operator | This operator does not work on these types, such as subtracting text from a number. | Check the types on both sides of the operator. |
'else' without 'if' | An else has no if right before it, often because of a ; after the condition or a missing brace. | Remove any ; after if (...) and check the braces. |
break outside switch or loop | break only works inside a loop or a switch. | Move it into the loop, or use return to leave the method. |
unreachable statement | Execution can never reach this line, such as a line after return or break. | Delete the line or move it before the statement that ends execution. |
method cannot be applied to given types | The arguments in this call do not match the method definition. | Match the number and types of arguments to the definition. |
class X is public, should be declared in a file named X.java | A public class name must match its file name exactly. | Rename the class or the file so that they match. |
integer number too large | This number is larger than an int can hold. | Use long and add L, such as 3000000000L. |
incompatible types | The type of this value does not fit what is needed here. | Check the type of the value and of the variable. |
ArithmeticException: / by zero | An integer was divided by zero while the program ran. | Check that the divisor is not zero before dividing. |
ArrayIndexOutOfBoundsException | This index is outside the array. Indexes run from 0 to length - 1. | Check the loop condition: use i < a.length, not i <= a.length. |
StringIndexOutOfBoundsException | This character position is outside the string. | Positions run from 0 to length() - 1. |
NullPointerException | You used a variable holding null, which refers to nothing. | Create the object or assign a value before using it. |
NumberFormatException | You tried to convert text to a number, but the text is not a valid number. | Check the text before calling Integer.parseInt. |
InputMismatchException | Scanner asked for a number but the input was text. | Enter the right type, or check with hasNextInt(). |
NoSuchElementException | The program asked for more input than was provided. | Match the number of reads to the input provided. |
IllegalFormatConversionException: d != java.lang.String | The format specifier does not fit the value, such as %d with text or a decimal. | Use %d for whole numbers, %f for decimals and %s for text. |
MissingFormatArgumentException: Format specifier '%d' | The template has more specifiers than values. | Give one value per specifier, in order. |
StackOverflowError | A method kept calling itself until the call stack filled up. | Add a stopping condition to the recursive method. |