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

📄 3.doc.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<code>	</code>the ASCII FF character, also known as "form feed"<br>
	<i>LineTerminator
</i></pre></ul><a name="48125"></a>
<h2>3.7    Comments</h2>
<a name="9724"></a>
Java defines three kinds of <i>comments</i>:
<p><a name="9727"></a>
 <code>/* </code><i>text</i><code> */		</code>A <i>traditional comment</i>: all the text from the ASCII characters <code>/*</code> to the ASCII characters <code>*/</code> is ignored (as in C and C++).<p>
<a name="9730"></a>
 <code>// </code><i>text		</i>A <i>single-line comment</i>: all the text from the ASCII characters <code>//</code> to the end of the line is ignored (as in C++).<p>
<a name="228965"></a>
 <code>/** </code><i>documentation</i><code> */</code>		A <i>documentation comment</i>: the text enclosed by the ASCII characters <code>/**</code> and <code>*/</code> can be processed by a separate tool to prepare automatically generated documentation of the following class, interface, constructor, or member (method or field) declaration. See <a href="18.doc.html#25978">&#167;18</a> for a full description of how the supplied <i>documentation</i> is processed.<p>
<a name="228969"></a>
These comments are formally specified by the following productions:
<p><ul><pre>
<i>Comment:<br>
</i>	<i>TraditionalComment<br>
</i>	<i>EndOfLineComment<br>
</i>	<i>DocumentationComment
</i>
<i>TraditionalComment</i>:<br>
	<code>/ * </code><i>NotStar</i><code> </code><i>CommentTail
</i>
<i>EndOfLineComment:<br>
</i>	<code>/ / </code><i>CharactersInLine</i><sub><i>opt</i></sub><code> </code><i>LineTerminator
</i>
<i>DocumentationComment:<br>
</i>	<code>/ * * </code><i>CommentTailStar
</i>
<i>CommentTail:<br>
</i>	<code>* </code><i>CommentTailStar<br>
</i>	<i>NotStar</i><code> </code><i>CommentTail
</i>
<i>CommentTailStar:<br>
</i>	<code>/<br>
	* </code><i>CommentTailStar<br>
</i>	<i>NotStarNotSlash</i><code> </code><i>CommentTail
</i>
<i>NotStar:<br>
</i>	<i>InputCharacter</i> but not <code>*<br>
</code>	<i>LineTerminator
</i>
<i>NotStarNotSlash:<br>
</i>	<i>InputCharacter</i> but not <code>*</code> or <code>/<br>
</code>	<i>LineTerminator
</i>
<i>CharactersInLine:<br>
</i>	<i>InputCharacter<br>
</i>	<i>CharactersInLine</i><code> </code><i>InputCharacter
</i></pre></ul><a name="230630"></a>
These productions imply all of the following properties:
<p><ul><a name="48132"></a>
<li>Comments do not nest.
<a name="48134"></a>
<li><code>/*</code> and <code>*/</code> have no special meaning in comments that begin with <code>//</code>.
<a name="48135"></a>
<li><code>//</code> has no special meaning in comments that begin with <code>/*</code> or <code>/**</code>.
</ul><a name="48136"></a>
As a result, the text:
<p><pre><a name="48137"></a>/*<code> </code>this comment /* // /** ends here: */
</pre><a name="230885"></a>
is a single complete comment.
<p><a name="230886"></a>
The lexical grammar implies that comments do not occur within character literals <a href="3.doc.html#100960">(&#167;3.10.4)</a> or string literals <a href="3.doc.html#101083">(&#167;3.10.5)</a>.<p>
<a name="229276"></a>
Note that <code>/**/</code> is considered to be a documentation comment, while <code>/* */ </code>(with a space between the asterisks) is a traditional comment.<p>
<a name="40625"></a>
<h2>3.8    Identifiers</h2>
<a name="229286"></a>
An <i>identifier</i> is an unlimited-length sequence of <i>Java letters</i> and <i>Java digits</i>, the 
first of which must be a Java letter. An identifier cannot have the same spelling 
(Unicode character sequence) as a keyword <a href="3.doc.html#229308">(&#167;3.9)</a>, Boolean literal <a href="3.doc.html#49652">(&#167;3.10.3)</a>, or 
the null literal <a href="3.doc.html#230717">(&#167;3.10.7)</a>.
<p><ul><pre>
<i>Identifier:<br>
</i>	<i>IdentifierChars</i> but not a <i>Keyword</i> or <i>BooleanLiteral</i> or <i>NullLiteral
</i>
<i>IdentifierChars:<br>
</i>	<i>JavaLetter<br>
</i>	<i>IdentifierChars</i><code> </code><i>JavaLetterOrDigit
</i>
<i>JavaLetter:<br>
</i>	any Unicode character that is a Java letter (see below)

<i>JavaLetterOrDigit:<br>
</i>	any Unicode character that is a Java letter-or-digit (see below)
</pre></ul><a name="23674"></a>
Letters and digits may be drawn from the entire Unicode character set, which supports most writing scripts in use in the world today, including the large sets for Chinese, Japanese, and Korean. This allows Java programmers to use identifiers in their programs that are written in their native languages.<p>
<a name="19216"></a>
A Java letter is a character for which the method <code>Character.isJavaLetter</code> <a href="javalang.doc4.html#9516">(&#167;20.5.17)</a> returns <code>true</code>. A Java letter-or-digit is a character for which the method <code>Character.isJavaLetterOrDigit</code> <a href="javalang.doc4.html#9166">(&#167;20.5.18)</a> returns <code>true</code>.<p>
<a name="230343"></a>
The Java letters include uppercase and lowercase ASCII Latin letters <code>A</code>-<code>Z</code> (<code>\u0041</code>-<code>\u005a</code>), and <code>a</code>-<code>z</code> <code>(\u0061</code>-<code>\u007a</code>), and, for historical reasons, the ASCII underscore (<code>_</code>, or <code>\u005f</code>) and dollar sign (<code>$</code>, or <code>\u0024</code>). The <code>$</code> character should be used only in mechanically generated Java code or, rarely, to access preexisting names on legacy systems.<p>
<a name="230344"></a>
The Java digits include the ASCII digits <code>0-9</code> (<code>\u0030</code>-<code>\u0039)</code>.<p>
<a name="230345"></a>
Two identifiers are the same only if they are identical, that is, have the same Unicode character for each letter or digit<em>.</em><p>
<a name="21262"></a>
Identifiers that have the same external appearance may yet be different. For example, the identifiers consisting of the single letters LATIN CAPITAL LETTER A (<code>A</code>, <code>\u0041</code>), LATIN SMALL LETTER A (<code>a</code>, <code>\u0061</code>), GREEK CAPITAL LETTER ALPHA (<code>A</code>, <code>\u0391</code>), and CYRILLIC SMALL LETTER A (<code>a</code>, <code>\u0430</code>) are all different.<p>
<a name="48270"></a>
Unicode composite characters are different from the decomposed characters. For example, a LATIN CAPITAL LETTER A ACUTE (<code>&Aacute;,</code> <code>\u00c1)</code> could be considered to be the same as a LATIN CAPITAL LETTER A (<code>A</code>, <code>\u0041)</code> immediately followed by a NON-SPACING ACUTE (&#180;, <code>\u0301</code>) when sorting, but these are different in Java identifiers. See <i>The Unicode Standard</i>, Volume 1, pages 412ff for details about decomposition, and see pages 626-627 of that work for details about sorting.<p>
<a name="31160"></a>
Examples of identifiers are:<p>
<pre><a name="31161"></a>	String			i3		<img src="chars/alpha.gif"><img src="chars/rho.gif"><img src="chars/epsilon.gif"><img src="chars/tau.gif"><img src="chars/eta.gif">			MAX_VALUE				isLetterOrDigit
</pre><a name="229308"></a>
<h2>3.9    Keywords</h2>
<a name="229309"></a>
The following character sequences, formed from ASCII letters, are reserved for 
use as <i>keywords</i> and cannot be used as identifiers <a href="3.doc.html#40625">(&#167;3.8)</a>:
<p><ul><pre>
<i>Keyword: one of<br>
</i><code>	abstract	default	if	private	throw<br>
	boolean	do	implements	protected	throws<br>
	break	double	import	public	transient<br>
	byte	else	instanceof	return	try<br>
	case	extends	int	short	void<br>
	catch	final	interface	static	volatile<br>
	char	finally	long	super	while<br>
	class	float	native	switch<br>
	const	for	new	synchronized<br>
	continue	goto	package	this
</code></pre></ul><a name="229316"></a>
The keywords <code>const</code> and <code>goto</code> are reserved by Java, even though they are not currently used in Java. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in Java programs.<p>
<a name="229317"></a>
While <code>true</code> and <code>false</code> might appear to be keywords, they are technically Boolean literals <a href="3.doc.html#49652">(&#167;3.10.3)</a>. Similarly, while <code>null</code> might appear to be a keyword, it is technically the null literal <a href="3.doc.html#230717">(&#167;3.10.7)</a>.<p>
<a name="48272"></a>
<h2>3.10    Literals</h2>
<a name="228794"></a>
A <i>literal</i> is the source code representation of a value of a primitive type <a href="4.doc.html#85587">(&#167;4.2)</a>, the 
<code>String</code> type (<a href="4.doc.html#26992">&#167;4.3.3</a>, <a href="javalang.doc11.html#14460">&#167;20.12</a>), or the null type <a href="4.doc.html#11128">(&#167;4.1)</a>:
<p><ul><pre>
<i>Literal:<br>
	IntegerLiteral<br>
	FloatingPointLiteral<br>
	BooleanLiteral<br>
	CharacterLiteral<br>
	StringLiteral<br>
	NullLiteral
</i></pre></ul><a name="48282"></a>
<h3>3.10.1    Integer Literals</h3>
<a name="46750"></a>
See <a href="4.doc.html#9151">&#167;4.2.1</a> for a general discussion of the integer types and values.
<p><a name="7117"></a>
An <i>integer literal</i> may be expressed in decimal (base 10), hexadecimal (base &#32;16), or octal (base 8):<p>
<ul><pre>
<i>IntegerLiteral:<br>
	DecimalIntegerLiteral<br>
	HexIntegerLiteral	<br>
	OctalIntegerLiteral
</i>
<i>DecimalIntegerLiteral:<br>
	DecimalNumeral</i><code> </code><i>IntegerTypeSuffix</i><sub><i>opt
</i></sub>
<i>HexIntegerLiteral:<br>
	HexNumeral</i><code> </code><i>IntegerTypeSuffix</i><sub><i>opt
</i></sub>
<i>OctalIntegerLiteral:	<br>
	OctalNumeral</i><code> </code><i>IntegerTypeSuffix</i><sub><i>opt
</i></sub>
<i>IntegerTypeSuffix:</i> <i>one</i> <i>of<br>

⌨️ 快捷键说明

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