https://blog.csdn.net/renfufei/article/details/17123473

翻译人员: 铁锚 翻译日期: 2013年12月4日 原文链接: Syntactic vs. Semantic vs. Runtime Errors

下面的三个例子演示了什么是语法错误、什么是语义错误以及什么是运行时错误。

语法错误(Syntactic Error)

如果一个程序包含语法错误,则不能通过编译.

public static int returnNull(){
	System.out.println("haha");
}

语义错误(Semantic Error)

如果程序包含了语义错误,则可以通过编译,但是得到的结果是错误的,或者不是所期望的功能。

public static int calSquareArea(int sideLength){
	return sideLength * 2;
}

运行时错误(Runtime Error)

Runtime errors 会在程序运行的时候发生。

public static void main(String[] args) {
	devideInt(4,0);
}

public static int devideInt(int a, int b){
	return a/b;
}

相关阅读:

  1. Latent Semantic Indexing
  2. How Compiler Works?
  3. Java Generic related problems
  4. An Example of Java Static Type Checking