声明式信息在编译时转换为命令形式,而不是在运行时每次使用时进行转换,这使代码更快。
The declarative information is transformed into an imperative form at compile-time, rather than each time it is used at runtime, resulting in faster code.
比如泛型更改——泛型类型信息——由编译器用于实施编译时安全,但是生成的字节码仍然到处使用强制转换。
Likewise with the generics changes — the generic type information is used by the compiler to enforce compile-time safe usage, but the generated bytecode still USES casts everywhere.
当装箱需要从int转换到Integer 时,编译器并不调用new Integer(int),而是生成对 Integer.valueOf(int) 的调用。
When boxing requires conversion from int to Integer, rather than calling new Integer(int), the compiler generates a call to Integer.valueOf(int).
隐含转换只在处理序不遗失资料时才会成功,否则会失败并且产生编译或执行阶段错误。
Implicit conversions succeed only when the process loses no data; otherwise they fail and generate a compile or run-time error.
在使用向上转换运算符时,编译器会尝试根据上下文来推断出要转换为的类型。
When you use the upcast operator, the compiler attempts to infer the type you are converting to from the context.
泛型相当有用,因为他们提供强制的编译时类型检查,要求更少的数据类型之间的显式转换,并减少装箱拆箱的操作和运行时类型检查。
Generics are useful because they provide stronger compile-time type checking, require fewer explicit conversions between data types, and reduce the need for boxing operations and run-time type checks.
当编译脚本时,字符串中的每个转义序列都会转换为它所表示的字符。
When a script is compiled, each escape sequence in a string literal is converted into the characters it represents.
在这种情况下,试图使用其他三种形式的强制转换都会导致编译时的错误。
Using any of the other three forms of cast in this case would result in a compile-time error.
当转换一个指针时,编译器只是添加合适偏移到指针上,进而指向在对象实例数据上。
When casting a pointer, the compiler simply adds the offset to the correct part of the object's instance data.
当转换一个指针时,编译器只是添加合适偏移到指针上,进而指向在对象实例数据上。
When casting a pointer, the compiler simply adds the offset to the correct part of the object's instance data.
应用推荐