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

📄 appb.htm

📁 JAVA Developing Professional JavaApplets
💻 HTM
📖 第 1 页 / 共 2 页
字号:
&nbsp;&nbsp;('extends' InterfaceName (',' InterfaceName)*)?<BR>&nbsp;&nbsp;'{' FieldDeclaration* '}'<BR>;</TT></BLOCKQUOTE><P>Interface declarations are similar to classes. The main differencebetween them is that interface declarations can extend one ormore existing interfaces.<BLOCKQUOTE><TT>FieldDeclaration =<BR>&nbsp;&nbsp;DocComment? MethodDeclaration<BR>| DocComment? ConstructorDeclaration<BR>| DocComment? VarableDeclaration<BR>| StaticInitializer<BR>| ';'<BR>;</TT></BLOCKQUOTE><P>DocComment is an undefined terminal. It takes the form of a multilinecomment beginning with <TT>/**</TT>and ending with the standard <TT>*/</TT>.<BLOCKQUOTE><TT>MethodDeclaration =<BR>&nbsp;&nbsp;Modifier* Type Identifier '(' ParameterList? ')' ('[' ']' )*<BR>&nbsp;&nbsp;( '{' Statement* '}' | ';' )<BR>;</TT></BLOCKQUOTE><P>Grammars enable syntactic constructs that cause the compiler toissue semantic errors. Notice that the body of a method is optional.Syntactically, this is correct. Semantically, however, this iscorrect only if a native or abstract modifier is present.<BLOCKQUOTE><TT>ConstructorDeclaration =<BR>&nbsp;&nbsp;Modifier* Identifier '(' ParameterList? ')'<BR>&nbsp;&nbsp;'{' Statement* '}'<BR>;<BR>VariableDeclaration =<BR>&nbsp;&nbsp;Modifier* Type VariableDeclarator (',' VariableDeclarator)*';'<BR>;<BR>VariableDeclarator =<BR>&nbsp;&nbsp;Identifier ('[' ']')* ('=' VariableInitializer)?<BR>;</TT></BLOCKQUOTE><P>A variable declarator may specify an array: <TT>intname[]</TT>. It also is legal for a Type to specify anarray: <TT>int[] name</TT>. Eitherform is correct.<BLOCKQUOTE><TT>VariableInitializer =<BR>&nbsp;&nbsp;Expression<BR>| '{' (VariableInitializer ( ',' VariableInitializer )* ','? )?'}'<BR>;</TT></BLOCKQUOTE><P>The second rule is for array initializations:<BLOCKQUOTE><TT>int x[] = { 1, 2, 3, 5, 9 };</TT></BLOCKQUOTE><P>The preceding statement creates an array of integers with a lengthof 5.<BLOCKQUOTE><TT>StaticInitializer =<BR>&nbsp;&nbsp;'static' '{' Statement* '}'<BR>;</TT></BLOCKQUOTE><P>You used a static initializer in <A HREF="ch10.htm" >Chapter 10</A>,&quot;Native Methods and Java,&quot; to load a native library:<BLOCKQUOTE><TT>ParameterList =<BR>&nbsp;&nbsp;Parameter (',' Parameter)*<BR>;<BR>Parameter =<BR>&nbsp;&nbsp;Type Identifier ('[' ']')*<BR>;<BR>Statement =<BR>&nbsp;&nbsp;VariableDeclaration<BR>| Expression ';'<BR>| '{' Statement* '}'<BR>| 'if' '(' Expression ')' Statement ('else' Statement)?<BR>| 'while' '(' Expression ')' Statement<BR>| 'do' Statement 'while' '(' Expression ')' ';'<BR>| 'for' '(' (VariableDeclaration | Expression ';' | ';')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Expression?';' Expression?')' Statement<BR>| 'try' Statement ('catch' '(' Parameter ')' Statement)*<BR>&nbsp;&nbsp;&nbsp;('finally' Statement)?<BR>| 'switch' '(' Expression ')' '{' Statement* '}'<BR>| 'synchronized' '(' Expression ')' Statement<BR>| 'return' Expression? ';'<BR>| 'throw' Expression ';'<BR>| 'case' Expression ':'<BR>| 'default' ':'<BR>| Identifier ':' Statement<BR>| 'break' Identifier? ';'<BR>| 'continue' Identifer? ';'<BR>| ';'<BR>;</TT></BLOCKQUOTE><P>Unlike C, break and continue have an optional identifier. Thisenables branching to a label. <TT>For</TT>loops may declare a new variable just as in C++. Notice that eachloop expression is optional.<P>Several control statements (<TT>if</TT>,<TT>while</TT>, and <TT>for</TT>)specify an expression in parentheses. Semantically, the expressionmust evaluate to a boolean type or an error is issued.<BLOCKQUOTE><TT>Expression =<BR>&nbsp;&nbsp;Expression '+' Expression<BR>| Expression '-' Expression<BR>| Expression '*' Expression<BR>| Expression '/' Expression<BR>| Expression '%' Expression<BR>| Expression '^' Expression<BR>| Expression '&amp;' Expression<BR>| Expression '|' Expression<BR>| Expression '&amp;&amp;' Expression<BR>| Expression '||' Expression<BR>| Expression '&lt;&lt;' Expression<BR>| Expression '&gt;&gt;' Expression<BR>| Expression '&gt;&gt;&gt;' Expression<BR>| Expression '=' Expression<BR>| Expression '+=' Expression<BR>| Expression '-=' Expression<BR>| Expression '*=' Expression<BR>| Expression '/=' Expression<BR>| Expression '%=' Expression<BR>| Expression '^=' Expression<BR>| Expression '&amp;=' Expression<BR>| Expression '|=' Expression<BR>| Expression '&lt;&lt;=' Expression<BR>| Expression '&gt;&gt;=' Expression<BR>| Expression '&gt;&gt;&gt;=' Expression<BR>| Expression '&lt;' Expression<BR>| Expression '&gt;' Expression<BR>| Expression '&lt;=' Expression<BR>| Expression '&gt;=' Expression<BR>| Expression '==' Expression<BR>| Expression '!=' Expression<BR>| Expression '.' Expression<BR>| Expression ',' Expression<BR>| Expression 'indtanceof' ( ClassName | InterfaceName )<BR>| Expression '?' Expression ':' Expression<BR>| ''++'' Expression<BR>| ''-''Expression<BR>| '++' Expression<BR>| '-'Expression<BR>| Expression '++'<BR>| Expression '-'<BR>| '-' Expression<BR>| '!' Expression<BR>| '~' Expression<BR>| '('Expression ')'<BR>| '(' Type ')' Expression<BR>| Expression '(' ArgList? ')'<BR>| 'new' ClassName '(' ArgList? ')'<BR>| 'new' TypeSpecifier ( '[' Expression ']' )+ ('[' ']')*<BR>| 'new' '(' Expression ')'<BR>| 'true'<BR>| 'false'<BR>| 'null'<BR>| 'super'<BR>| 'this'<BR>| Identifier<BR>| Number<BR>| String<BR>| Character<BR>;</TT></BLOCKQUOTE><P>Comparison expressions always evaluate to a boolean expression.<P>Declaring new arrays can be confusing. The syntax states thatthere must be a <TT>new</TT> keywordfollowed by a type and one or more defined dimensions: <TT>newint[2][3]</TT>. A trailing undefined dimension is alsoallowed: <TT>new int[2][3][]</TT>.The following is not legal because there must be one or more defineddimensions: <TT>new int[]</TT>.<BLOCKQUOTE><TT>ArgList =<BR>&nbsp;&nbsp;Expression (',' Expression )*<BR>;<BR>Type =<BR>&nbsp;&nbsp;TypeSpecifier ('[' ']')*<BR>;</TT></BLOCKQUOTE><P>Here is the second method for declaring an array: <TT>int[]name</TT>.<BLOCKQUOTE><TT>TypeSpecifier =<BR>&nbsp;&nbsp;'boolean'<BR>| 'byte'<BR>| 'char'<BR>| 'short'<BR>| 'int'<BR>| 'float'<BR>| 'long'<BR>| 'double'<BR>| ClassName<BR>| InterfaceName<BR>;<BR>Modifier =<BR>&nbsp;&nbsp;'public'<BR>| 'private'<BR>| 'protected'<BR>| 'static'<BR>| 'final'<BR>| 'native'<BR>| 'synchronized'<BR>| 'abstract'<BR>| 'threadsafe'<BR>| 'transient'<BR>;<BR>PackageName =<BR>&nbsp;&nbsp;Identifier<BR>| PackageName '.' Identifier<BR>;<BR>ClassName =<BR>&nbsp;&nbsp;Identifier<BR>| PackageName '.' Identifier<BR>;<BR>InterfcaeName =<BR>&nbsp;&nbsp;Identifer<BR>| PackageName '.' Identifier<BR>;</TT></BLOCKQUOTE><P><HR WIDTH="100%"></P></P></CENTER><P><HR WIDTH="100%"></P><!-- reference library footer #1--></CENTER><IMG SRC="/images/rule.gif" WIDTH="460" HEIGHT="5" VSPACE="5"ALT="Ruler image"><br><FONT SIZE="-1">Contact <a href="mailto:reference@developer.com">reference@developer.com</a> with questions or comments.<br><a href="/legal/">Copyright 1998</a> <a href="http://www.earthweb.com" target="_top">EarthWeb Inc.</a>,  All rights reserved.<BR>PLEASE READ THE <a href="/reference/usage.html">ACCEPTABLE USAGE STATEMENT</a>.<BR>Copyright 1998 Macmillan Computer Publishing. All rights reserved.</FONT></BLOCKQUOTE><!--outer table--><TD VALIGN="TOP"><!--right side ads --><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCAD1.REF" alt="Click here for more info"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCAD1.REF" alt="Click here for more info" height="88" width="88" border="0"></a><P><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCAD2.REF" alt="Click here for more info"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCAD2.REF" alt="Click here for more info" height="88" width="88" border="0"></a><P></td></tr></table></BODY></HTML>

⌨️ 快捷键说明

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