📄 039-041.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=039-041//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch01/034-038.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="041-045.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 2<BR>Java Programming: The Basics
</FONT></H2>
<P ALIGN="RIGHT">“I don’t know what the programming language of the year 2000 will look like, but I know that it will be named FORTRAN.”
</P>
<P ALIGN="RIGHT"><I>—Tony Hoare, 1984</I></P>
<P>This chapter introduces you to Java. We assume that you are an experienced programmer in a structured language such as C or Pascal or that you have some background in object-oriented programming. We divide the subject of the Java language into two parts: syntax and semantics. We take a different path from that of the Java specification. The Java specification organizes the material by package, but we organize the material by concept. Thus, we place the wrapper classes (<I>Boolean</I>, <I>Character</I>, <I>Integer</I>, <I>Long</I>, <I>Float</I> and <I>Double</I>) into a single wrapper class subsection that resides in the section devoted to data types. We have found that the <I>java.lang</I> package does not present functions for maximum clarity of organization. For example, we prefer not to present threads and integers in the same subsection, they are basically unrelated topics even though they reside in the same package.</P>
<P>This chapter is divided into four main sections. The first section describes the notation we have devised to assist us with the presentation of Java syntax. We have devised this language to describe the grammar of Java. Because it is a language for describing languages, it is called a <I>metalanguage</I>. We base our metalanguage on a Backus Naur Form with some modifications. We refer to our version of the Backus Naur Form as Modified Backus Naur Form (MBNF).</P>
<P>Next, we discuss semantics of the Java language using examples. Often we will present several incarnations of Java usage in context. These incarnations are taken from working programs.</P>
<P>The second section covers the simple syntax of Java. Simple syntax includes those structures that are already familiar to C or C++ programmers. You may feel comfortable skipping or skimming this section.</P>
<P>In the third section we detail the data types in Java, including the object-oriented and the non-object-oriented data types.</P>
<P>The fourth section covers threads and provides several examples of multithreaded Java programs.</P>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">MBNF Notation</FONT></H3>
<P>In this book we use MBNF to describe the syntax of Java. We use the translate functor of Prolog, ->, as the digraphic symbol meaning “can be written as” [Clocksin]. People who study formal languages refer to the -> symbol as a <I>production</I>. Java does not use the -> symbol, because Java has no pointers. We have found that the standard notation, as used in the Java specification, is hard to match on the blackboard during lectures. We wanted a compact notation whose typeset appearance would not deviate significantly from its hand-written appearance. This meant no bold or italic font could be used in the syntax definition.</P>
<P>The meta-symbols of BNF are shown in Table 2.1.</P>
<TABLE WIDTH="100%"><CAPTION><B>Table 2.1</B> BNF Metasymbols
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="30%" ALIGN="LEFT">Metasymbol
<TH WIDTH="70%" ALIGN="LEFT">Meaning
<TR>
<TD>->
<TD>can be written as
<TR>
<TD>(X|Y)
<TD>grouping alternatively, X or Y
<TR>
<TD VALIGN="TOP">< >
<TD>syntactic construct, non-terminal symbol meta identifier
<TR>
<TD>[X]
<TD>0 or 1 instance of X
<TR>
<TD>{X}
<TD>0 or more instances of X
<TR>
<TD>““
<TD>terminal
<TR>
<TD>.
<TD>end of production
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>As an example, we show MBNF in MBNF:
</P>
<!-- CODE //-->
<PRE>
syntax -> { production }.
production -> identifier “->” expression “.” .
expression -> term { “|” term } .
term -> factor { factor } .
factor -> identifier |
quotedSymbol |
“(“ expression “)” |
“[“ expression “]” |
“{“ expression “}” .
identifier -> letter { letter | digit } .
quotedSymbol -> “”” { anyCharacter } “”” .
</PRE>
<!-- END CODE //-->
<P>The syntax of a language will permit the formulation of a statement that compiles. The syntax does not describe the meaning of the statement however, nor does it describe the common usage. For this, we use examples and prose.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch01/034-038.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="041-045.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 + -