The following are three Java examples for showing what are syntax error, semantic error, and runtime error.
Syntactic Error
If a program contains syntax error, it will not pass compilation.
public static int returnNull(){ System.out.println("haha"); } |
Semantic Error
If a program contains only semantic errors, it means that it can pass compilation, but does not do what it meant to do. It c
public static int calSquareArea(int sideLength){ return sideLength * 2; } |
Runtime Error
Runtime errors happen during program run-time.
public static void main(String[] args) { devideInt(4,0); } public static int devideInt(int a, int b){ return a/b; } |