翻译人员: 铁锚
翻译日期: 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

相关文章:

  • 2021-08-27
  • 2021-08-22
  • 2021-07-08
  • 2021-10-11
  • 2022-02-08
  • 2022-12-23
  • 2021-05-25
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-08
相关资源
相似解决方案