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

📄 tij0075.html

📁 学习java的经典书籍
💻 HTML
字号:
<html><body>

<table width="100%"><tr>
<td>
<a href="http://www.bruceeckel.com/javabook.html">Bruce Eckel's Thinking in Java</a>
</td>
<td align="right">
<a href="tij_c.html">Contents</a> | <a href="tij0074.html">Prev</a> | <a href="tij0076.html">Next</a>
</td>
</tr></table>
<hr>

<H1 ALIGN=LEFT>
7:
Polymorphism
<P><A NAME="Index549"></A></H1>
<DIV ALIGN=LEFT><FONT FACE="Calligraph421 BT" SIZE=4 COLOR="Black">Polymorphism
is the third essential feature of an object-oriented programming language,
after data abstraction and inheritance. 
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">It
provides another dimension of separation of interface from implementation, to
decouple 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>what</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
from 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>how</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
Polymorphism allows improved code organization and readability as well as the
creation of 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>extensible</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
programs that can be &#8220;grown&#8221; not only during the original creation
of the project but also when new features are desired.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Encapsulation
creates new data types by combining characteristics and behaviors.
Implementation hiding separates the interface from the implementation by making
the details 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>private</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
This sort of mechanical organization makes ready sense to someone with a
procedural programming background. But polymorphism deals with <A NAME="Index550"></A>decoupling
in terms of 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>types</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
In the last chapter, you saw how <A NAME="Index551"></A>inheritance
allows the treatment of an object as its own type 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>or</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
its base type. This ability is critical because it allows many types (derived
from the same base type) to be treated as if they were one type, and a single
piece of code to work on all those different types equally. The <A NAME="Index552"></A>polymorphic
method call allows one type to express its distinction from another, similar
type, as long as they&#8217;re both derived from the same base type. This
distinction is expressed through differences in behavior of the methods you can
call through the base class.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">In
this chapter, you&#8217;ll learn about polymorphism (also called <A NAME="Index553"></A><A NAME="Index554"></A><A NAME="Index555"></A><A NAME="Index556"></A></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>dynamic
binding
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
or 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>late
binding
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
or 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>run-time
binding
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">)</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">starting
from the basics, with simple examples that strip away everything but the
polymorphic behavior of the program.
</FONT><a name="_Toc305593263"></a><a name="_Toc305628735"></a><a name="_Toc312374040"></a><a name="_Toc375545327"></a><a name="_Toc408018530"></a><P></DIV>

<div align="right">
<a href="tij_c.html">Contents</a> | <a href="tij0074.html">Prev</a> | <a href="tij0076.html">Next</a>
</div>
</body></html>

⌨️ 快捷键说明

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