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

📄 what is an object.mht

📁 什么是对象
💻 MHT
📖 第 1 页 / 共 3 页
字号:
From: <由 Microsoft Internet Explorer 5 保存>
Subject: What Is an Object?
Date: Fri, 6 Sep 2002 23:26:03 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
	boundary="----=_NextPart_000_0043_01C255FC.C47AB1D0";
	type="text/html"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

This is a multi-part message in MIME format.

------=_NextPart_000_0043_01C255FC.C47AB1D0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://java.sun.com/docs/books/tutorial/java/concepts/object.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>What Is an Object?</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<SCRIPT language=3DJavaScript>=0A=
<!-- hide=0A=
function openWin(term) {=0A=
  url=3D"../../information/glossary.html#" + term;=0A=
  myWin=3D window.open(url, "Glossary",=0A=
              =
"width=3D400,height=3D150,scrollbars=3Dyes,status=3Dno,toolbar=3Dno,menub=
ar=3Dno");=0A=
  myWin.focus();=0A=
}=0A=
//-->=0A=
</SCRIPT>

<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY link=3D#000099 bgColor=3D#ffffff><B><FONT size=3D-1>The =
Java</FONT><SUP><FONT=20
size=3D-2>TM</FONT></SUP> <FONT size=3D-1>Tutorial</FONT></B> <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><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><FONT size=3D-1><B>Trail</B>: =
Learning the=20
Java Language <BR><B>Lesson</B>: Object-Oriented Programming Concepts =
</FONT>
<H2>What Is an Object? </H2>
<BLOCKQUOTE>Objects are key to understanding <A=20
  onmouseover=3D"self.status=3D'Look up object-oriented in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('object-oriented%20design=
');"><FONT=20
  color=3D#00bb00><EM>object-oriented</EM></FONT></A><A=20
  onmouseover=3D"self.status=3D'Look up object-oriented in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('object-oriented%20design=
');"><IMG=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> technology. You can look around you =
now and see=20
  many examples of real-world objects: your dog, your desk, your =
television set,=20
  your bicycle.=20
  <P>These real-world objects share two characteristics: They all have=20
  <EM>state</EM> and <EM>behavior</EM>. For example, dogs have state =
(name,=20
  color, breed, hungry) and behavior (barking, fetching, and wagging =
tail).=20
  Bicycles have state (current gear, current pedal cadence, two wheels, =
number=20
  of gears) and behavior (braking, accelerating, slowing down, changing =
gears).=20
  <P>Software objects are modeled after real-world objects in that they =
too have=20
  state and behavior. A software object maintains its state in one or =
more <A=20
  onmouseover=3D"self.status=3D'Look up variables in glossary'; return =
true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  href=3D"javascript:var%20meth=3DopenWin;%20meth('variable');"><FONT=20
  color=3D#00bb00><EM>variables</EM></FONT></A><A=20
  onmouseover=3D"self.status=3D'Look up variables in glossary'; return =
true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  href=3D"javascript:var%20meth=3DopenWin;%20meth('variable');"><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>. A variable is an item of data named =
by an=20
  identifier. A software object implements its behavior with <A=20
  onmouseover=3D"self.status=3D'Look up methods in glossary'; return =
true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  href=3D"javascript:var%20meth=3DopenWin;%20meth('method');"><FONT=20
  color=3D#00bb00><EM>methods</EM></FONT></A><A=20
  onmouseover=3D"self.status=3D'Look up methods in glossary'; return =
true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  href=3D"javascript:var%20meth=3DopenWin;%20meth('method');"><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>. A method is a function (subroutine) =
associated=20
  with an object.=20
  <BLOCKQUOTE>
    <HR>
    <STRONG>Definition:</STRONG>&nbsp;An object is a software bundle of=20
    variables and related methods.=20
    <HR>
  </BLOCKQUOTE>You can represent real-world objects by using software =
objects.=20
  You might want to represent real-world dogs as software objects in an=20
  animation program or a real-world bicycle as a software object in the =
program=20
  that controls an electronic exercise bike. You can also use software =
objects=20
  to model abstract concepts. For example, an <EM>event</EM> is a common =
object=20
  used in GUI window systems to represent the action of a user pressing =
a mouse=20
  button or a key on the keyboard.=20
  <P>The following illustration is a common visual representation of a =
software=20
  object:=20
  <P>
  <CENTER><IMG height=3D133 alt=3D""=20
  src=3D"http://java.sun.com/docs/books/tutorial/figures/java/con17.gif" =
width=3D317=20
  align=3Dbottom NATURALSIZEFLAG=3D"3"></CENTER>
  <P></P>Everything that the software object knows (state) and can do =
(behavior)=20
  is expressed by the variables and the methods within that object. A =
software=20
  object that modeled your real-world bicycle would have variables that=20
  indicated the bicycle's current state: its speed is 10 mph, its pedal =
cadence=20
  is 90 rpm, and its current gear is the 5th gear. These variables are =
formally=20
  known as <A=20
  onmouseover=3D"self.status=3D'Look up instance variables in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('instance%20variable');">=
<FONT=20
  color=3D#00bb00><EM>instance variables</EM></FONT></A><A=20
  onmouseover=3D"self.status=3D'Look up instance variables in glossary'; =
return true;"=20
  onmouseout=3D"self.status=3D''; return true;"=20
  =
href=3D"javascript:var%20meth=3DopenWin;%20meth('instance%20variable');">=
<IMG=20

⌨️ 快捷键说明

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