运行时和编译时的区别是什么?
当前回答
简单地说,b/w编译时间和运行时间的差异。
编译时:开发人员以.java格式编写程序,并将其转换为类文件字节码,在编译期间发生的任何错误都可以定义为编译时错误。
运行时:生成的.class文件被应用程序用于它的附加功能&逻辑是错误的,并抛出一个错误,这是一个运行时错误
其他回答
运行时和编译时的主要区别是:
如果代码中存在语法错误和类型检查,则抛出编译时错误,而-as运行时:它在执行代码后进行检查。 例如:
Int a = 1 Int b = a/0;
这里的第一行末尾没有分号——在执行操作b时执行程序后,>编译时错误,结果是无限的——>运行时错误。
编译时不会查找代码提供的功能的输出,而运行时则会。
简单地说,b/w编译时间和运行时间的差异。
编译时:开发人员以.java格式编写程序,并将其转换为类文件字节码,在编译期间发生的任何错误都可以定义为编译时错误。
运行时:生成的.class文件被应用程序用于它的附加功能&逻辑是错误的,并抛出一个错误,这是一个运行时错误
编译时间:您作为开发人员编译代码的时间段。
运行时间:用户运行你的软件的时间段。
你需要更明确的定义吗?
作为其他答案的补充,以下是我对外行的解释:
您的源代码就像一艘船的蓝图。它定义了船应该如何制造。
如果你把你的蓝图交给造船厂,他们在建造船的时候发现了一个缺陷,他们会立即停止建造并向你报告,在船离开干船坞或接触水之前。这是一个编译时错误。这艘船甚至从未真正漂浮过,也没有使用过它的引擎。这个错误之所以被发现,是因为它甚至阻止了这艘船的制造。
当您的代码编译完成时,就像船完成了一样。建好了,可以出发了。当你执行你的代码时,就像在航行中让船下水一样。乘客上了船,引擎在运转船体在水面上,这是运行时间。如果你的船有致命的缺陷,在处女航时就沉没了(或者可能是一些额外的麻烦),那么它就遇到了运行错误。
Imagine that you are a boss and you have an assistant and a maid, and you give them a list of tasks to do, the assistant (compile time) will grab this list and make a checkup to see if the tasks are understandable and that you didn't write in any awkward language or syntax, so he understands that you want to assign someone for a Job so he assign him for you and he understand that you want some coffee, so his role is over and the maid (run time)starts to run those tasks so she goes to make you some coffee but in sudden she doesn’t find any coffee to make so she stops making it or she acts differently and make you some tea (when the program acts differently because he found an error).