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

📄 what is an object.mht

📁 什么是对象
💻 MHT
📖 第 1 页 / 共 3 页
字号:
  height=3D11 alt=3D"(in the glossary)"=20
  =
src=3D"http://java.sun.com/docs/books/tutorial/images/glossaryIcon.gif" =
width=3D11=20
  align=3DabsMiddle border=3D0></A> because they contain the state for a =
particular=20
  bicycle object, and in object-oriented terminology, a particular =
object is=20
  called an <EM>instance</EM>.=20
  <P>The following figure illustrates a bicycle modeled as a software =
object.=20
  <P>
  <CENTER><IMG height=3D133 alt=3D""=20
  src=3D"http://java.sun.com/docs/books/tutorial/figures/java/con18.gif" =
width=3D230=20
  align=3Dbottom NATURALSIZEFLAG=3D"3"></CENTER>
  <P></P>In addition to its variables, the software bicycle would also =
have=20
  methods to brake, change the pedal cadence, and change gears. (The =
bike would=20
  not have a method for changing the speed of the bicycle, as the bike's =
speed=20
  is just a side effect of what gear it's in, how fast the rider is =
pedaling,=20
  whether the brakes are on, and how steep the hill is.) These methods =
are=20
  formally known as <A=20
  onmouseover=3D"self.status=3D'Look up instance methods in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('instance%20method');"><F=
ONT=20
  color=3D#00bb00><EM>instance methods</EM></FONT></A><A=20
  onmouseover=3D"self.status=3D'Look up instance methods in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('instance%20method');"><I=
MG=20
  height=3D11 alt=3D"(in the glossary)"=20
  =
src=3D"http://java.sun.com/docs/books/tutorial/images/glossaryIcon.gif" =
width=3D11=20
  align=3DabsMiddle border=3D0></A> because they inspect or change the =
state of a=20
  particular bicycle instance.=20
  <P>The object diagrams show that the object's variables make up the =
center, or=20
  nucleus, of the object. Methods surround and hide the object's nucleus =
from=20
  other objects in the program. Packaging an object's variables within =
the=20
  protective custody of its methods is called <A=20
  onmouseover=3D"self.status=3D'Look up encapsulation in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('encapsulation');"><FONT =

  color=3D#00bb00><EM>encapsulation</EM></FONT></A><A=20
  onmouseover=3D"self.status=3D'Look up encapsulation in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('encapsulation');"><IMG =
height=3D11=20
  alt=3D"(in the glossary)"=20
  =
src=3D"http://java.sun.com/docs/books/tutorial/images/glossaryIcon.gif" =
width=3D11=20
  align=3DabsMiddle border=3D0></A> This conceptual picture of an =
object-a nucleus=20
  of variables packaged within a protective membrane of methods-is an =
ideal=20
  representation of an object and is the ideal that designers of =
object-oriented=20
  systems strive for. However, it's not the whole story. Often, for =
practical=20
  reasons, an object may wish to expose some of its variables or hide =
some of=20
  its methods. In the Java programming language, an object can specify =
one of=20
  four access levels for each of its variables and methods. The access =
level=20
  determines which other objects and classes can access that variable or =
method.=20
  Variable and method access in Java is covered in <A=20
  =
href=3D"http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol=
.html"=20
  target=3D_top>Controlling Access to Members of a Class</A><A=20
  =
href=3D"http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol=
.html"=20
  target=3D_top><IMG height=3D11 alt=3D"(in the Learning the Java =
Language trail)"=20
  =
src=3D"http://java.sun.com/docs/books/tutorial/images/tutorialIcon.gif" =
width=3D11=20
  align=3DabsMiddle border=3D0></A>. Encapsulating related variables and =
methods=20
  into a neat software bundle is a simple yet powerful idea that =
provides two=20
  primary benefits to software developers:=20
  <UL>
    <LI><B>Modularity:</B> The source code for an object can be written =
and=20
    maintained independently of the source code for other objects. Also, =
an=20
    object can be easily passed around in the system. You can give your =
bicycle=20
    to someone else, and it will still work.=20
    <LI><B>Information hiding:</B> An object has a public interface that =
other=20
    objects can use to communicate with it. The object can maintain =
private=20
    information and methods that can be changed at any time without =
affecting=20
    the other objects that depend on it. You don't need to understand =
the gear=20
    mechanism on your bike to use it. </LI></UL></BLOCKQUOTE><IMG =
height=3D8=20
src=3D"http://java.sun.com/docs/books/tutorial/images/blueline.gif" =
width=3D550=20
align=3Dbottom NATURALSIZEFLAG=3D"3"> <BR>
<TABLE width=3D550>
  <TBODY>
  <TR>
    <TD vAlign=3Dcenter align=3Dleft><A=20
      =
href=3D"http://java.sun.com/docs/books/tutorial/java/concepts/index.html"=
=20
      target=3D_top><IMG height=3D26 alt=3D"Previous Page"=20
      =
src=3D"http://java.sun.com/docs/books/tutorial/images/PreviousArrow.gif" =

      width=3D26 align=3Dcenter border=3D0></A> <A=20
      =
href=3D"http://java.sun.com/docs/books/tutorial/java/TOC.html#concepts"=20
      target=3D_top><IMG height=3D26 alt=3D"Lesson Contents"=20
      src=3D"http://java.sun.com/docs/books/tutorial/images/TOCIcon.gif" =
width=3D26=20
      align=3Dcenter border=3D0></A> <A=20
      =
href=3D"http://java.sun.com/docs/books/tutorial/java/concepts/message.htm=
l"=20
      target=3D_top><IMG height=3D26 alt=3D"Next Page"=20
      =
src=3D"http://java.sun.com/docs/books/tutorial/images/NextArrow.gif"=20
      width=3D26 align=3Dcenter border=3D0></A></TD>
    <TD vAlign=3Dcenter align=3Dmiddle><FONT size=3D-1><A=20
      href=3D"http://java.sun.com/docs/books/tutorial/index.html"=20
      target=3D_top>Start of Tutorial</A> &gt; <A=20
      href=3D"http://java.sun.com/docs/books/tutorial/java/index.html"=20
      target=3D_top>Start of Trail</A> &gt; <A=20
      =
href=3D"http://java.sun.com/docs/books/tutorial/java/concepts/index.html"=
=20
      target=3D_top>Start of Lesson</A> </FONT></TD>
    <TD vAlign=3Dcenter align=3Dright><FONT size=3D-1><A=20
      href=3D"http://java.sun.com/docs/books/tutorial/search.html"=20
      target=3D_top>Search</A> <BR><A=20
      =
href=3D"http://java.sun.com/docs/books/tutorial/forms/sendusmail.html">Fe=
edback=20
      Form</A> </FONT></TD></TR></TBODY></TABLE>
<P><FONT size=3D-1><A=20
href=3D"http://java.sun.com/docs/books/tutorial/information/copyright.htm=
l">Copyright</A>=20
1995-2002 Sun Microsystems, Inc. All rights reserved. =
</FONT></P></BODY></HTML>

------=_NextPart_000_0043_01C255FC.C47AB1D0
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://java.sun.com/docs/books/tutorial/images/PreviousArrow.gif

R0lGODdhGgAaAPUAAPf8//Hy9+34/+bu/97e3tbW3tLh+87W3snN28TS9LvG3LG52ae856XG56O4
96Cu1p2nwJy955y155S155St54+o2Y+awIyt54yl54ea1oSl54Sc54OVwn6LvHuc53uU53uT2nuM
53OM53OM3nOE1nKM03KE3m+BvWuE1muEzmt7zmN7zmN7xmN7vV9zvV50sV5zxlBouEpgrUpaljdP
nwokeQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGgAaAAAG/sCGsBEpFiWSiZJC
uTgxUI1mkxkaj8llswnFSDdg4TWCVE6Y3MolqslQiUYJ2TypoCVM7xTsGSMrEQABAQCFhgNTbhke
IFdJFRWEBYaUCWAbHhsgfUeQGYUDC5SGEoqMjEd1JQEJJzKfowAYfBkfIB9IEhUnFgcuMhaTsYuL
H8YjfyAvFgbBsQ8AA3y2HyMhjx3AsQAKLzWFm7e2ISNKuzIQlAEP3jXfANQgIuTlFBks2oIL7e79
/tUjRjTJ0EIbAn7+EtYQEdDEwIIWoiV40EJhQoYkUDyU0UEiA138HDBg4WLFCBMZUTi5J+PEoQQM
GOyrkUABCxYoSOhEkeJCnoUMrl6MMgBTJgABGXIqTaECSoYUMmbEGgBTQSEGJVBkZdr0J1QahKYO
AJWSKwsvG0rIoGGBwDZKSVMwvdkmbQwaM/DKeHGig98OHDJUGGGWBQwpGUCweCFjbVQakGk0ZqFC
roqbMFpcAgGC500XMVy8iDHaBQumK26SdEFFEyMQI7KimJ1iRW0VuFW72A0mnK2AwDOSsHyZRYvd
ooMAADs=

------=_NextPart_000_0043_01C255FC.C47AB1D0
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://java.sun.com/docs/books/tutorial/images/TOCIcon.gif

R0lGODlhGgAaAPcAAPz8//v7/vz8/v7+/+ns+uXp+/P1/vn6/vf4/HOBt3B9rX+Owo+e0ouZy5im
26a16sDH4vDz/vDy+WJzqWJyp5Kh1Jur4KCw5au78LDA9bK+5c3V8ODl9u3w+kZhqVVppGZ6tpur
26W147DA8Ku657XF8Kay1sTS+7XB4dzk++Xr/ezv+O/x9/v8//r7/vn6/fj5/AAlfgkthBAzhxEz
hyBAjyFBjydGlDBOlzFOl0VgoVdxr1VtqWV7sWZ8sXeLvnaKun6Rv4WXxImaxIqbxLXH8qKw0r7N
8qq21NTb7M/W5/f5/vb4/WR7sXWKuoOWwoygy4iaxImbxKvA8JqpzLvL8Ky62dTg/LvF3Nnk/ODn
9+vx/t/k7+/0/+7z/vL2//L1/LDF8Ka327fH58DQ8LrF3Nrk+MzV5/D1//b5//X4/u7x9/j6/vf5
/fz9//v8/omi0cvV5+bu/fP3/vH1/LXL8OLs/O7z+/X4/bvQ8Onx/e/1/vL2/Pn7/vL3/vf6/vX4

⌨️ 快捷键说明

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