📄 045-047.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1558515682"><META name=vstitle content="Java Digital Signal Processing"><META name=vsauthor content="Douglas A. Lyon"><META name=vsimprint content="M&T Books"><META name=vspublisher content="IDG Books Worldwide, Inc."><META name=vspubdate content="11/01/97"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Java Digital Signal Processing:Java Programming: The Basics</TITLE>
<!-- HEADER --><STYLE type="text/css"> <!-- A:hover { color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=1558515682//-->
<!--TITLE=Java Digital Signal Processing//-->
<!--AUTHOR=Douglas A. Lyon//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=2//-->
<!--PAGES=045-047//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="041-045.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="047-050.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Simple Syntax</FONT></H3>
<P>This section covers the aspects of Java that are familiar to an experienced programmer. Experienced C/C++ programmers will be tempted to skim or skip it. The differences between Java syntax and C/C++ syntax are small: documentation comments and an extension to the <I>for</I> loop. You will probably do fine if you read these two sections and then skip to data types.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>MBNF discussed in the previous section, will be reintroduced and sometimes extended as new syntactic features are covered.<HR></FONT>
</BLOCKQUOTE>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Comments</FONT></H4>
<P>There are three types of comments in Java:
</P>
<DL>
<DD><B>•</B> C-style comments that begin with /* and end with */
<DD><B>•</B> C++-style comments that begin with // and end at the end of a line
<DD><B>•</B> javadoc-style comments that start with /** and end with */
</DL>
<P>Comments in Java are just like those of C++. For example:
</P>
<!-- CODE SNIP //-->
<PRE>
// This is a comment
/* and so is
this
*/
</PRE>
<!-- END CODE SNIP //-->
<P>There are good rules of style to be followed when using comments. For example, use C-style comments when you have multiple lines, because C++-style comments require the // in front of every line. For example:
</P>
<!-- CODE SNIP //-->
<PRE>
/* This is a multi
line comment
it is easier to type
because you don’t need a
// in front
of every line.
*/
</PRE>
<!-- END CODE SNIP //-->
<P>The C++-style comment is excellent for writing short comments. The end of the line denotes the end of the comment, and you don’t have to worry about the terminating */.
</P>
<P>Javadoc comments start with a /** and end with a */. The MBNF for the javadoc comment is as follows:</P>
<!-- CODE SNIP //-->
<PRE>
docComment -> “/**” “... text ...”
“*/” .
</PRE>
<!-- END CODE SNIP //-->
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CD-ROM: </B>The JDK javadoc tool reads Java source code and scans for the javadoc comments. When they are encountered, javadoc generates HTML. These documentation comments are typically included before a class declaration, class member, or constructor. Code will work without them, but it is good practice to include them. They are not supported by all development tools and, more specifically, are not supported by Metrowerks CodeWarrior. As a result, we do not use the javadoc comments in this book. Instead, we have built a custom documentation generator that comes on the CD-ROM with this book.<HR></FONT>
</BLOCKQUOTE>
<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Identifiers</FONT></H4>
<P>An <I>identifier</I> starts with a letter and then contains letters or digits. It may not contain a keyword. Identifiers in Java may be of unlimited length. Recall rule 48:</P>
<!-- CODE SNIP //-->
<PRE>
identifier ->
“a..z,$,_” < “a..z,$,_,0..9,unicode
character over 00C0” > .
</PRE>
<!-- END CODE SNIP //-->
<P>The MBNF for the keyword follows:
</P>
<!-- CODE SNIP //-->
<PRE>
keyword -> “abstract” | “default” |“if” | “private” | “throw”
| “boolean” |“do” | “implements” |“protected” | “throws” | “break”
| “double” | “import” | “public” | “transient” | “byte” | “else” |
“instanceof” | “return” | “try” | “case” | “extends” | “int” | “short”
| “void” | “catch” | “final” | “interface” | “static” | “volatile” | “char”
| “finally” | “long” | “super” | “while” | “class” | “float” | “native”
| “switch” | “const” | “for” | “new” | “synchronized” | “continue”
|“goto”| “package” |“this”.
</PRE>
<!-- END CODE SNIP //-->
<P>We were quite impressed when the following compiled and ran:
</P>
<!-- CODE SNIP //-->
<PRE>
int theUnlimitedLengthConstraintOfThe_Java_Identifiers_can_bring_1234
Interesting_Variables_into_your_code = 90;
</PRE>
<!-- END CODE SNIP //-->
<P>We were also surprised when <I>goto</I> was listed as one of the keywords. Java does not support <I>goto</I> but reserves the <I>goto</I> keyword so that it may not be used as an identifier.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Operators discussed next are not permitted as a part of the identifier. Identifiers are used in several places in Java, as discussed in the following sections.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="041-045.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="047-050.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright © <a href="/reference/idgbooks00001.html">IDG Books Worldwide, Inc.</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --></BODY></HTML><!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -