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

📄 008-010.html

📁 dshfghfhhgsfgfghfhfghgfhfghfgh fg hfg hh ghghf hgf hghg gh fg hg hfg hfh f hg hgfh gkjh kjkh g yj f
💻 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 and Its Promise</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=1//-->
<!--PAGES=008-010//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="006-008.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="011-012.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>Java Has No Multiple Inheritance</B></FONT></P>
<P>Multiple inheritance, as it was known in C&#43;&#43;, has been eliminated in Java. Multiple inheritance is the ability to have two or more direct base classes. In 1966, Ole-Johan Dahl rejected multiple inheritance as a feature in Simula, reasoning that it would complicate garbage collection. Smalltalk does not support multiple inheritance either [Stroustrup 1994].
</P>
<P>The problem with multiple inheritance is that duplicate class variables and method names must override each other, according to a policy that becomes a part of the language and can often be forgotten by the programmer. Elimination of multiple inheritance reduces the possibility that programmers will get confused about which method is in effect. It also limits the kinds of inheritance that can be performed. Java permits only an a-kind-of (AKO) taxonomy of class inheritance. Figure 1.4 shows an example of AKO class inheritance.</P>
<P><A NAME="Fig4"></A><A HREF="javascript:displayWindow('images/01-04.jpg',384,193 )"><IMG SRC="images/01-04t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/01-04.jpg',384,193)"><FONT COLOR="#000077"><B>Figure 1.4</B></FONT></A>&nbsp;&nbsp;Example of AKO inheritance.</P>
<P>In Java, an animal class can be extended to create a mammal subclass, thereby indicating that a mammal is a kind of animal. Because a student and a professor are both humans, they also inherit traits of mammals. In most other object-oriented languages, you can mix two or more AKO inheritance chains. Figure 1.5 shows an example of multiple inheritance.
</P>
<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/01-05.jpg',424,244 )"><IMG SRC="images/01-05t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/01-05.jpg',424,244)"><FONT COLOR="#000077"><B>Figure 1.5</B></FONT></A>&nbsp;&nbsp;An example of multiple inheritance.</P>
<P>With multiple inheritance, the attributes associated with the <I>stream</I> class, can be inherited by both the <I>input-stream</I> and the <I>output-stream</I>. When these two classes are joined by a third class, the <I>input-output-stream</I>, we have multiple inheritance. This language feature enables programmers to reuse the data structures and methods of two parent classes.</P>
<P>There is no doubt that method name ambiguity must be resolved at either compile time or at run time. And because Java must load libraries dynamically, it seems that the ambiguity would have to be resolved by the class loader. We suggest that one reason Java eliminated multiple inheritance was to promote implementation simplicity.</P>
<P>The removal of multiple inheritance is a design trade-off. The decision to remove multiple inheritance probably helped the code become more reliable, simplified garbage collection, and simplified the class loader. Programmers who are used to having multiple inheritance, however, will probably miss it.</P>
<P><FONT SIZE="+1"><B>Java Has No gotos</B></FONT></P>
<P>There are no gotos in Java. It is possible, however, to perform a multiloop break using the <I>break &lt;label&gt;</I> feature. Goto removal is a good thing, because it will probably lead to better codes and eliminate a common source of bugs.</P>
<P><FONT SIZE="+1"><B>Java Has No Global Variables</B></FONT></P>
<P>Java has no global variables. Instead, it gives you access to classes that have variables and methods. By restricting visibility, you can permit public access. When you apply access control to a class that has a static class variable, it could be argued that the variable is global to all other classes through the class name. The variable is accessed by <I>className.variableName</I>. For example, <I>Math.PI</I> is a global reference to a class variable.</P>
<P><FONT SIZE="+1"><B>Java Has No Macros</B></FONT></P>
<P>Java has no preprocessor and no macro language (as in RatFor, C, and C&#43;&#43;). There are no compiler directives. It is not possible, as in C, to create language extensions. For example:
</P>
<!-- CODE SNIP //-->
<PRE>
#define &#123; Begin
</PRE>
<!-- END CODE SNIP //-->
<P>This statement, which would create an ALGOL or Pascal-like style for code blocks, would confuse the code editor. It is not permitted in Java.
</P>
<P>C/C&#43;&#43; macro facilities permit confusing function call errors. For example:</P>
<!-- CODE SNIP //-->
<PRE>
#define cube(x) x * x * x
x = cube(x&#43;1);
</PRE>
<!-- END CODE SNIP //-->
<P>This code expands into the following:
</P>
<!-- CODE SNIP //-->
<PRE>
x = x &#43; 1 * x &#43; 1 * x &#43; 1;
</PRE>
<!-- END CODE SNIP //-->
<P>Thus, <I>x</I> becomes 3*<I>x</I> &#43;1 and not <I>x</I>*<I>x</I>*<I>x</I>.</P>
<P><FONT SIZE="+1"><B>Java Has Only Object Oriented Structures</B></FONT></P>
<P>There are no structures or union operations in Java. All the types are implemented as classes. This arrangement is probably a good thing, because the data manipulation methods can be built into the data structures.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="006-008.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="011-012.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>

<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright &copy; <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 + -