⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 concepts.doc.html

📁 一本关于java方面的书籍 英文html形式 关于Java虚拟机
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<li>If T is a class type, then T must be <code>Object</code>.<a name="19933"></a><li>If T is an interface type, then T must be the same interface as S, or T a superinterface of S.<a name="19944"></a><li>If S is an array type SC<code>[]</code>, that is, an array of components of type SC:<a name="19951"></a><li>If T is a class type, then T must be <code>Object</code>.<a name="27293"></a><li>If T is an interface type, then T must be <code>Cloneable</code>.<a name="20006"></a><li>If T is an array type, namely, the type TC<code>[]</code>, array of components of type TC, then either<a name="20010"></a><li>TC and SC must be the same primitive type, or<a name="20011"></a><li>TC and SC are both reference types and type SC is assignable to TC.</ul><a name="19685"></a><h3>2.6.7	 Method Invocation Conversion</h3><a name="25833"></a><i>Method invocation conversion</i> is applied to each argument value in a method or constructor invocation: the type of the argument expression must be converted to the type of the corresponding parameter. Method invocation contexts allow the use of an identity conversion <a href="Concepts.doc.html#19691">(&#167;2.6.1)</a>, a widening primitive conversion <a href="Concepts.doc.html#23435">(&#167;2.6.2)</a>, or a widening reference conversion <a href="Concepts.doc.html#25679">(&#167;2.6.4)</a>. Method invocation conversions specifically do not include the implicit narrowing of integer constants that is part of assignment conversion <a href="Concepts.doc.html#19674">(&#167;2.6.6)</a>.<p><a name="18168"></a><h3>2.6.8	 Casting Conversions</h3><a name="19492"></a><i>Casting conversions </i>are more powerful than assignment or method invocation conversions applied to the operand of a cast operator: the type of the operand expression must be converted to the type explicitly named by the cast operator. Casting contexts allow the use of an identity conversion <a href="Concepts.doc.html#19691">(&#167;2.6.1)</a>, a widening primitive conversion <a href="Concepts.doc.html#23435">(&#167;2.6.2)</a>, a narrowing primitive conversion <a href="Concepts.doc.html#26142">(&#167;2.6.3)</a>, a widening reference conversion <a href="Concepts.doc.html#25679">(&#167;2.6.4)</a>, or a narrowing reference conversion <a href="Concepts.doc.html#25683">(&#167;2.6.5)</a>. Thus, casting conversions are more inclusive than assignment or method invocation conversions: a cast can do any permitted conversion other than a string conversion.<p><a name="18837"></a>Casting can convert a value of any numeric type to any other numeric type. A value of type <code>boolean</code> cannot be cast to another type. A value of reference type cannot be cast to a value of primitive type. <p><a name="20937"></a>Some casts can be proven incorrect at compile time and result in a compile-time error. Otherwise, either the cast can be proven correct at compile time, or a runtime validity check is required. (See <i>The Java Language Specification</i> for details.) If the value at run time is a null reference, then the cast is allowed. If the check at run time fails, a <code>ClassCastException</code> is thrown.<p><a name="16021"></a><h3>2.6.9	 Numeric Promotion</h3><a name="16022"></a><i>Numeric promotion </i>is applied to the operands of an arithmetic operator. Numeric promotion contexts allow the use of an identity conversion <a href="Concepts.doc.html#19691">(&#167;2.6.1)</a> or a widening primitive conversion <a href="Concepts.doc.html#23435">(&#167;2.6.2)</a><i>.</i><p><a name="25960"></a>Numeric promotions are used to convert the operands of a numeric operator to a common type where an operation can be performed. The two kinds of numeric promotion are <i>unary numeric promotion</i> and <i>binary numeric promotion</i>. The analogous conversions in C are called "the usual unary conversions" and "the usual binary conversions." Numeric promotion is not a general feature of Java, but rather a property of the specific definitions of built-in operators. <p><a name="20080"></a>An operator that applies unary numeric promotion to a single operand of numeric type converts an operand of type <code>byte</code>, <code>short</code>, or <code>char</code> to <code>int</code>, and otherwise leaves the operand alone. The operands of the shift operators are promoted independently using unary numeric promotions.<p><a name="20091"></a>When an operator applies binary numeric promotion to a pair of numeric operands, the following rules apply, in order, using widening conversion <a href="Concepts.doc.html#23435">(&#167;2.6.2)</a> to convert operands as necessary:<p><ul><a name="18184"></a><li>If either operand is of type <code>double</code>, the other is converted to <code>double</code>.<a name="18185"></a><li>Otherwise, if either operand is of type <code>float</code>, the other is converted to <code>float</code>.<a name="18186"></a><li>Otherwise, if either operand is of type <code>long</code>, the other is converted to <code>long</code>.<a name="18187"></a><li>Otherwise, both operands are converted to type <code>int</code>.</ul><a name="21272"></a><hr><h2>2.7	 Names and Packages</h2><a name="21410"></a><h3>2.7.1	 Names</h3><a name="18205"></a><i>Names</i> are used to refer to entities declared in a Java program. A declared entity is a package, type, member (field or method) of a type, parameter, or local variable. <p><a name="18217"></a>A <i>simple </i>name is a single identifier <a href="Concepts.doc.html#25339">(&#167;2.2)</a>. <i>Qualified</i> names provide access to members of packages and reference types. A qualified name <a href="Concepts.doc.html#18914">(&#167;2.7.8)</a> consists of a name, a "." token, and an identifier. <p><a name="18902"></a>Not all identifiers in Java programs are part of a name. Identifiers are also used in declarations, where the identifier determines the name by which an entity will be known, in field access expressions and method invocation expressions, and in statement labels and <code>break</code> and <code>continue</code> statements which refer to statement labels.<p><a name="20319"></a><h3>2.7.2	 Packages</h3><a name="18906"></a>Java programs are organized sets of <i>packages</i>. A package consists of a number of compilation units and has an hierarchical name. Packages are independently developed, and each package has its own set of names, which helps to prevent name conflicts.<p><a name="20321"></a>Each Java host determines how packages, compilation units, and subpackages are created and stored; which top-level package names are in scope in a particular compilation; and which packages are accessible. Packages may be stored in a local file system, in a distributed file system, or in some form of database.<p><a name="20320"></a>A package name component or class name might contain a character that cannot legally appear in a host file system's ordinary directory or file name: for instance, a Unicode character on a system that allows only ASCII characters in file names. <p><a name="26168"></a>A Java system must support at least one unnamed package; it may support more than one unnamed package but is not required to do so. Which compilation units are in each unnamed package is determined by the host system. Unnamed packages are provided by Java principally for convenience when developing small or temporary applications or when just beginning development.<p><a name="20328"></a>An <code>import</code> declaration allows a type declared in another package to be known by a simple name rather than by the fully qualified name <a href="Concepts.doc.html#20207">(&#167;2.7.9)</a> of the type. An import declaration affects only the type declarations of a single compilation unit. A compilation unit automatically imports each of the <code>public</code> type names declared in the predefined package <code>java.lang</code>.<p><a name="26049"></a><h3>2.7.3	 Members</h3><a name="26053"></a>Packages and reference types have <i>members</i>. The members of a package <a href="Concepts.doc.html#20319">(&#167;2.7.2)</a> are subpackages and all the class <a href="Concepts.doc.html#16198">(&#167;2.8)</a> and interface <a href="Concepts.doc.html#16432">(&#167;2.13)</a> types declared in all the compilation units of the package. The members of a reference type are fields <a href="Concepts.doc.html#16338">(&#167;2.9)</a> and methods <a href="Concepts.doc.html#16317">(&#167;2.10)</a>.<p><a name="27480"></a><h3>2.7.4	 Package Members</h3><a name="27485"></a>The members of a package are its <i>subpackages</i> and types declared in the compilation units of the package.<p><a name="27481"></a>In general, the subpackages of a package are determined by the host system. However, the standard package <code>java</code> always has the subpackages <code>lang</code>, <code>util</code>, <code>io</code>, and <code>net</code>. No two distinct members of the same package may have the same simple name <a href="Concepts.doc.html#21410">(&#167;2.7.1)</a>, but members of different packages may have the same simple name.<p><a name="26071"></a><h3>2.7.5	 The Members of a Class Type</h3><a name="26072"></a>The members of a class type <a href="Concepts.doc.html#16198">(&#167;2.8)</a> are fields <a href="Concepts.doc.html#16338">(&#167;2.9)</a> and methods <a href="Concepts.doc.html#16317">(&#167;2.10)</a>. These include members inherited from its direct superclass <a href="Concepts.doc.html#20358">(&#167;2.8.3)</a>, if it has one, members inherited from any direct superinterfaces <a href="Concepts.doc.html#20603">(&#167;2.13.2)</a>, and any members declared in the body of the class. There is no restriction against a field and a method of a class type having the same simple name. <p><a name="26073"></a>A class type may have two or more methods with the same simple name if they have different numbers of parameters or different parameter types in at least one parameter position. Such a method member name is said to be <i>overloaded</i>. A class type may contain a declaration for a method with the same name and the same signature as a method that would otherwise be inherited from a superclass or superinterface. In this case, the method of the superclass or superinterface is not inherited. If the method not inherited is <code>abstract</code>, the new declaration is said to <i>implement</i> it; if it is not <code>abstract</code>, the new declaration is said to <i>override</i> it.<p><a name="26076"></a><h3>2.7.6	 The Members of an Interface Type</h3><a name="26077"></a>The members of an interface type <a href="Concepts.doc.html#16432">(&#167;2.13)</a> are fields and methods. The members of an interface are the members inherited from any direct superinterfaces <a href="Concepts.doc.html#20603">(&#167;2.13.2)</a> and members declared in the body of the interface.<p><a name="26078"></a><h3>2.7.7	 The Members of an Array Type</h3><a name="26079"></a>The members of an array type <a href="Concepts.doc.html#16446">(&#167;2.14)</a> are the members inherited from its superclass, the class <code>Object</code> <a href="Concepts.doc.html#27433">(&#167;2.4.6)</a>, and the field <code>length</code>, which is a constant (<code>final</code>) field of every array.<p><a name="18914"></a><h3>2.7.8	 Qualified Names and Access Control</h3><a name="18915"></a>Qualified names <a href="Concepts.doc.html#21410">(&#167;2.7.1)</a> are a means of access to members of packages and reference types; related means of access include field access expressions and method invocation expressions. All three are syntactically similar in that a "." token appears, preceded by some indication of a package, type, or expression having a type and followed by an identifier that names a member of the package or type. These are collectively known as constructs for <i>qualified access</i>. <p><a name="18923"></a>Java provides mechanisms for limiting qualified access, to prevent users of a package or class from depending on unnecessary details of the implementation of that package or class. Access control also applies to constructors.<p><a name="26122"></a>Whether a package is accessible is determined by the host system.<p><a name="26129"></a>A class or interface may be declared <code>public</code>, in which case it may be accessed, using a qualified name, by any Java code that can access the package in which it is declared. A class or interface that is not declared <code>public</code> may be accessed from, and only from, anywhere in the package in which it is declared.<p><a name="26130"></a>Every field or method of an interface must be <code>public</code>. Every member of a <code>public</code> interface is implicitly <code>public</code>, whether or not the keyword <code>public</code> appears in its declaration. If an interface is not <code>public</code>, then every one of its fields and methods must be explicitly declared <code>public</code>. It follows that a member of an interface is accessible if and only if the interface itself is accessible.<p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -