简体   繁体   English

类型转换/类型绑定/类型推断等的编译时或运行时

[英]Compile time or Runtime for type casting/ type binding / type inference etc

I am relatively new to Java and I had an exam past year that got me stuck. 我是Java的新手,过去一年的考试使我陷入困境。

The task asked me to differentiate which options run at Compilation time / Runtime. 任务要求我区分在编译时/运行时运行哪些选项。

  1. Type casting. 类型转换。
  2. Late binding. 后期绑定。
  3. Accessibility checking. 辅助功能检查。
  4. Type inference. 类型推断。
  5. Type erasure. 类型擦除。
  6. Type checking. 类型检查。

Are there any sources I can read to improve my understanding on static / dynamic binding? 有什么资料可以阅读,以增进我对静态/动态绑定的理解?

  • Type casting - Compile time but could not be catched and throw ClassCastException ( Java Type Casting ) 类型转换 - 编译时但无法捕获并抛出ClassCastExceptionJava类型转换
  • Late binding - Runtime in general and Compile time for calls to final, private, or static methods ( Late Binding in Java ) 后期绑定 -调用final,private或static方法的常规运行 时间编译时Java中的后期绑定
  • Accessibility checking - Access modifiers are solely a compile time mechanism in C++. 访问性检查 -Access修饰符仅是C ++中的编译时机制。 In Java however, they are enforced at runtime too, because Java also has a runtime typesystem, and it can dynamically (at runtime) create classes. 但是,在Java中,它们也可以在运行时强制执行,因为Java也具有运行时类型系统,并且可以动态(在运行时)创建类。 So it needs to enforce access at runtime too for types it doesn't know about at compile time. 因此,对于在编译时不知道的类型,它也需要在运行时强制执行访问。 ( OOP Access Modifiers: Compile-time or Run-time ) OOP访问修饰符:编译时或运行时
  • Type inference - Compile time - Type inference is a Java compiler's ability to look at each method invocation and corresponding declaration to determine the type argument (or arguments) that make the invocation applicable ( Type Inference ) 类型推断 - 编译时 -类型推断是Java编译器查看每个方法调用和相应声明以确定使调用适用的类型参数的能力( 类型推断 )。
  • Type erasure - Compile time - Type erasure can be explained as the process of enforcing type constraints only at compile time and discarding the element type information at runtime ( Type Erasure in Java ) 类型擦除 - 编译时 -类型擦除可以解释为仅在编译时强制执行类型约束并在运行时丢弃元素类型信息的过程( Java中的Type Erasure )。
  • Type checking - Compile time but facilitating runtime type checking eg via instanceof ( What are the things are checked at compile time by Java? ) 类型检查 - 编译时,但便于运行时类型检查,例如通过instanceofJava在编译时检查什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM