分享
 
 
 

java.net.NetworkInterface翻译

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--NewPage-->

<HTML>

<HEAD>

<!-- Generated by javadoc (build 1.4.2-rc) on Fri Jun 13 00:14:24 PDT 2003 -->

<TITLE>

NetworkInterface (Java 2 Platform SE v1.4.2)

</TITLE>

<META NAME="keywords" CONTENT="java.net.NetworkInterface class">

<META NAME="keywords" CONTENT="getName()">

<META NAME="keywords" CONTENT="getInetAddresses()">

<META NAME="keywords" CONTENT="getDisplayName()">

<META NAME="keywords" CONTENT="getByName()">

<META NAME="keywords" CONTENT="getByInetAddress()">

<META NAME="keywords" CONTENT="getNetworkInterfaces()">

<META NAME="keywords" CONTENT="equals()">

<META NAME="keywords" CONTENT="hashCode()">

<META NAME="keywords" CONTENT="toString()">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">

function windowTitle()

{

parent.document.title="NetworkInterface (Java 2 Platform SE v1.4.2)";

}

</SCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">

<!-- ========= START OF TOP NAVBAR ======= -->

<A NAME="navbar_top"><!-- --></A>

<A HREF="#skip-navbar_top" title="Skip navigation links"></A>

<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">

<TR>

<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">

<A NAME="navbar_top_firstrow"><!-- --></A>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">

<TR ALIGN="center" VALIGN="top">

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/NetworkInterface.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>

</TR>

</TABLE>

</TD>

<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>

<b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.4.2</b></EM>

</TD>

</TR>

<TR>

<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">

&nbsp;<A HREF="../../java/net/NetPermission.html" title="class in java.net"><B>PREV CLASS</B></A>&nbsp;

&nbsp;<A HREF="../../java/net/PasswordAuthentication.html" title="class in java.net"><B>NEXT CLASS</B></A></FONT></TD>

<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">

<A HREF="../../index.html" target="_top"><B>FRAMES</B></A> &nbsp;

&nbsp;<A HREF="NetworkInterface.html" target="_top"><B>NO FRAMES</B></A> &nbsp;

&nbsp;<SCRIPT type="text/javascript">

<!--

if(window==top) {

document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');

}

//-->

</SCRIPT>

<NOSCRIPT>

<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>

</NOSCRIPT>

</FONT></TD>

</TR>

<TR>

<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">

SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>

<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">

DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>

</TR>

</TABLE>

<A NAME="skip-navbar_top"></A>

<!-- ========= END OF TOP NAVBAR ========= -->

<HR>

<!-- ======== START OF CLASS DATA ======== -->

<H2>

<FONT SIZE="-1">

java.net</FONT>

<BR>

Class NetworkInterface</H2>

<PRE>

<A HREF="../../java/lang/Object.html" title="class in java.lang">java.lang.Object</A>

<IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>java.net.NetworkInterface</B>

</PRE>

<HR>

<DL>

<DT>public final class <B>NetworkInterface</B><DT>extends <A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></DL>

<P>

This class represents a Network Interface made up of a name,

and a list of IP addresses assigned to this interface.

It is used to identify the local interface on which a multicast group

is joined.

Interfaces are normally known by names such as "le0".

该类表示由名称表示的网络接口及其分配给此接口的IP地址列表,用于标识加入多播组的本地接口。

借口一般使用名称如“le0”。

<P>

<P>

<DL>

<DT><B>Since:</B></DT>

<DD>1.4</DD>

</DL>

<HR>

<P>

<!-- ======== NESTED CLASS SUMMARY ======== -->

<!-- =========== FIELD SUMMARY =========== -->

<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>

<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">

<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">

<TD COLSPAN=2><FONT SIZE="+2">

<B>Method Summary</B></FONT></TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>&nbsp;boolean</CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#equals(java.lang.Object)">equals</A></B>(<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A>&nbsp;obj)</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Compares this object against the specified object.

将该对象与指定对象比较。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>static&nbsp;<A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#getByInetAddress(java.net.InetAddress)">getByInetAddress</A></B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;addr)</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convenience method to search for a network interface that

has the specified Internet Protocol (IP) address bound to

it.

查找被绑定到指定IP地址的网络接口的便捷方法。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>static&nbsp;<A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#getByName(java.lang.String)">getByName</A></B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A>&nbsp;name)</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Searches for the network interface with the specified name.

查找指定名称的网络接口的便捷方法。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>&nbsp;<A HREF="../../java/lang/String.html" title="class in java.lang">String</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#getDisplayName()">getDisplayName</A></B>()</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the display name of this network interface.

获得此网络接口的显示名称。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>&nbsp;<A HREF="../../java/util/Enumeration.html" title="interface in java.util">Enumeration</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#getInetAddresses()">getInetAddresses</A></B>()</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convenience method to return an Enumeration with all or a

subset of the InetAddresses bound to this network interface.

返回绑定到此网络接口的所有InetAddresse或子集的便捷方法。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>&nbsp;<A HREF="../../java/lang/String.html" title="class in java.lang">String</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#getName()">getName</A></B>()</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the name of this network interface.

获得此网络接口的名称。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>static&nbsp;<A HREF="../../java/util/Enumeration.html" title="interface in java.util">Enumeration</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#getNetworkInterfaces()">getNetworkInterfaces</A></B>()</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns all the interfaces on this machine.

返回此机器的所有接口。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>&nbsp;int</CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#hashCode()">hashCode</A></B>()</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a hash code value for the object.

返回该对象的hash码值。</TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

<CODE>&nbsp;<A HREF="../../java/lang/String.html" title="class in java.lang">String</A></CODE></FONT></TD>

<TD><CODE><B><A HREF="../../java/net/NetworkInterface.html#toString()">toString</A></B>()</CODE>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a string representation of the object.

返回该对象的字符串形式。</TD>

</TR>

</TABLE>

&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>

<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">

<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">

<TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></B></TD>

</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">

<TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD>

</TR>

</TABLE>

&nbsp;

<P>

<!-- ============ FIELD DETAIL =========== -->

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>

<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">

<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">

<TD COLSPAN=1><FONT SIZE="+2">

<B>Method Detail</B></FONT></TD>

</TR>

</TABLE>

<A NAME="getName()"><!-- --></A><H3>

getName</H3>

<PRE>

public <A HREF="../../java/lang/String.html" title="class in java.lang">String</A> <B>getName</B>()</PRE>

<DL>

<DD>Get the name of this network interface.

获得此网络接口的名称。

<P>

<DD><DL>

<DT><B>Returns:</B><DD>the name of this network interface 此网络接口的名称</DL>

</DD>

</DL>

<HR>

<A NAME="getInetAddresses()"><!-- --></A><H3>

getInetAddresses</H3>

<PRE>

public <A HREF="../../java/util/Enumeration.html" title="interface in java.util">Enumeration</A> <B>getInetAddresses</B>()</PRE>

<DL>

<DD>Convenience method to return an Enumeration with all or a

subset of the InetAddresses bound to this network interface.

返回绑定到此网络接口的所有InetAddresse或子集的便捷方法。

<p>

If there is a security manager, its <code>checkConnect</code>

method is called for each InetAddress. Only InetAddresses where

the <code>checkConnect</code> doesn't throw a SecurityException

will be returned in the Enumeration.

如果存在安全管理器,对每个地址调用checkConnect方法,只有checkConnect不抛出SecurityException,才会在枚举中返回。

<P>

<DD><DL>

<DT><B>Returns:</B><DD>an Enumeration object with all or a subset of the InetAddresses

bound to this network interface 绑定到此网络接口的所有InetAddresse或子集的便捷方法。</DL>

</DD>

</DL>

<HR>

<A NAME="getDisplayName()"><!-- --></A><H3>

getDisplayName</H3>

<PRE>

public <A HREF="../../java/lang/String.html" title="class in java.lang">String</A> <B>getDisplayName</B>()</PRE>

<DL>

<DD>Get the display name of this network interface.

A display name is a human readable String describing the network

device.

获得此网络接口的显示名称。显示名称是指描述网络设备的可读字符串。

<P>

<DD><DL>

<DT><B>Returns:</B><DD>the display name of this network interface,

or null if no display name is available. 此网络接口的显示名称,如果没有可用的显示名称,返回null。</DL>

</DD>

</DL>

<HR>

<A NAME="getByName(java.lang.String)"><!-- --></A><H3>

getByName</H3>

<PRE>

public static <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A> <B>getByName</B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A>&nbsp;name)

throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>

<DL>

<DD>Searches for the network interface with the specified name.

查找指定名称的网络接口的便捷方法。

<P>

<DD><DL>

<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the network interface. 网络接口的名称。

<DT><B>Returns:</B><DD>A <tt>NetworkInterface</tt> with the specified name,

or <tt>null</tt> if there is no network interface

with the specified name. 指定名称的网络接口,如果没有指定名称的网络接口,返回null。

<DT><B>Throws:</B>

<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - If an I/O error occurs. 如果I/O错误发生则抛出。

<DD><CODE><A HREF="../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</A></CODE> - If the specified name is <tt>null</tt>. 如果指定的地址为null,则抛出。</DL>

</DD>

</DL>

<HR>

<A NAME="getByInetAddress(java.net.InetAddress)"><!-- --></A><H3>

getByInetAddress</H3>

<PRE>

public static <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A> <B>getByInetAddress</B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;addr)

throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>

<DL>

<DD>Convenience method to search for a network interface that

has the specified Internet Protocol (IP) address bound to

it.

查找被绑定到指定IP地址的网络接口的便捷方法。

<p>

If the specified IP address is bound to multiple network

interfaces it is not defined which network interface is

returned.

如果指定的IP地址被绑定到多个网络接口,返回的网络接口不确定。

<P>

<DD><DL>

<DT><B>Parameters:</B><DD><CODE>addr</CODE> - The <tt>InetAddress</tt> to search with. 要查找的InetAddress。

<DT><B>Returns:</B><DD>A <tt>NetworkInterface</tt>

or <tt>null</tt> if there is no network interface

with the specified IP address.

返回网络接口,如果指定的IP地址没有网络接口,返回null。

<DT><B>Throws:</B>

<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - If an I/O error occurs. 如果I/O错误发生则抛出。

<DD><CODE><A HREF="../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</A></CODE> - If the specified address is <tt>null</tt>. 如果指定的地址为null,则抛出。</DL>

</DD>

</DL>

<HR>

<A NAME="getNetworkInterfaces()"><!-- --></A><H3>

getNetworkInterfaces</H3>

<PRE>

public static <A HREF="../../java/util/Enumeration.html" title="interface in java.util">Enumeration</A> <B>getNetworkInterfaces</B>()

throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>

<DL>

<DD>Returns all the interfaces on this machine. Returns null if no

network interfaces could be found on this machine.

NOTE: can use getNetworkInterfaces()+getInetAddresses()

to obtain all IP addresses for this node

返回此机器的所有接口。如果在此机器上找不到网络接口返回null。

注意:可以使用getNetworkInterfaces()+getInetAddresses() 来获取此节点的所有IP地址。

<P>

<DD><DL>

<DT><B>Returns:</B><DD>an Enumeration of NetworkInterfaces found on this machine 在此机器上找到的网络接口的枚举

<DT><B>Throws:</B>

<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if an I/O error occurs. 如果I/O错误发生则抛出。</DL>

</DD>

</DL>

<HR>

<A NAME="equals(java.lang.Object)"><!-- --></A><H3>

equals</H3>

<PRE>

public boolean <B>equals</B>(<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A>&nbsp;obj)</PRE>

<DL>

<DD>Compares this object against the specified object.

The result is <code>true</code> if and only if the argument is

not <code>null</code> and it represents the same NetworkInterface

as this object.

将该对象与指定对象比较。只有参数不为null,且同此对象表示相同的网络接口才返回true。

<p>

Two instances of <code>NetworkInterface</code> represent the same

NetworkInterface if both name and addrs are the same for both.

如果名称和地址都相同,两个NetworkInterface实例才表示相同的网络接口。

<P>

<DD><DL>

<DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></CODE></DL>

</DD>

<DD><DL>

<DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to compare against. 要比较的对象。

<DT><B>Returns:</B><DD><code>true</code> if the objects are the same;

<code>false</code> otherwise. 如果对象相同,返回true,否则为false。<DT><B>See Also:</B><DD><A HREF="../../java/net/InetAddress.html#getAddress()"><CODE>InetAddress.getAddress()</CODE></A></DL>

</DD>

</DL>

<HR>

<A NAME="hashCode()"><!-- --></A><H3>

hashCode</H3>

<PRE>

public int <B>hashCode</B>()</PRE>

<DL>

<DD><B>Description copied from class: <CODE><A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></CODE></B></DD>

<DD>Returns a hash code value for the object. This method is

supported for the benefit of hashtables such as those provided by

<code>java.util.Hashtable</code>.

返回该对象的hash码值。使用此方法在于利用如java.util.Hashtable的散列表的优势。

<p>

The general contract of <code>hashCode</code> is:

hashCode的通常约定:

<ul>

<li>Whenever it is invoked on the same object more than once during

an execution of a Java application, the <tt>hashCode</tt> method

must consistently return the same integer, provided no information

used in <tt>equals</tt> comparisons on the object is modified.

This integer need not remain consistent from one execution of an

application to another execution of the same application.

无论何时在Java应用程序执行的过程中多次调用同一个对象,hashCode方法必须始终返回同样的整数,并假定

用于equals比较的信息没有被修改。该整数从一个应用的执行到同样应用的另一次执行则不必保持一致。

<li>If two objects are equal according to the <tt>equals(Object)</tt>

method, then calling the <code>hashCode</code> method on each of

the two objects must produce the same integer result.

如果根据equals(Object)方法,两个对象相等,那么这两个对象分别调用hashCode方法必定生成相同的整数结果。

<li>It is <em>not</em> required that if two objects are unequal

according to the <A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>Object.equals(java.lang.Object)</CODE></A>

method, then calling the <tt>hashCode</tt> method on each of the

two objects must produce distinct integer results. However, the

programmer should be aware that producing distinct integer results

for unequal objects may improve the performance of hashtables.

如果根据Object.equals(java.lang.Object)方法两个对象不相等,不要求两个对象分别调用hashCode方法必定生成不同的整数结果。

然而,程序员应该意识到不同对象生成不同的整数结果可以改善散列表的性能。

</ul>

<p>

As much as is reasonably practical, the hashCode method defined by

class <tt>Object</tt> does return distinct integers for distinct

objects. (This is typically implemented by converting the internal

address of the object into an integer, but this implementation

technique is not required by the

Java<font size="-2"><sup>TM</sup></font> programming language.)

根据实际情况,类Object定义的hashCode方法对不同对象返回不同的整数。(通常以对象的内部地址转换成整数方式实现,但该实现技术

在Java程序语言中不要求)

<P>

<DD><DL>

<DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#hashCode()">hashCode</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></CODE></DL>

</DD>

<DD><DL>

<DT><B>Returns:</B><DD>a hash code value for this object. 此对象的hash码值。<DT><B>See Also:</B><DD><A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>Object.equals(java.lang.Object)</CODE></A>,

<A HREF="../../java/util/Hashtable.html" title="class in java.util"><CODE>Hashtable</CODE></A></DL>

</DD>

</DL>

<HR>

<A NAME="toString()"><!-- --></A><H3>

toString</H3>

<PRE>

public <A HREF="../../java/lang/String.html" title="class in java.lang">String</A> <B>toString</B>()</PRE>

<DL>

<DD><B>Description copied from class: <CODE><A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></CODE></B></DD>

<DD>Returns a string representation of the object. In general, the

<code>toString</code> method returns a string that

"textually represents" this object. The result should

be a concise but informative representation that is easy for a

person to read.

It is recommended that all subclasses override this method.

返回该对象的字符串形式。通常,toString方法返回一个对象文本表示的字符串。结果应简明但易于读懂。

<p>

The <code>toString</code> method for class <code>Object</code>

returns a string consisting of the name of the class of which the

object is an instance, the at-sign character `<code>@</code>', and

the unsigned hexadecimal representation of the hash code of the

object. In other words, this method returns a string equal to the

value of:

类Object的toString方法返回一个包括类实例的类名称的字符串,“@”字符和此对象的无符号十六进制表示。

换句话说,该方法返回的字符串等于:

<blockquote>

<pre>

getClass().getName() + '@' + Integer.toHexString(hashCode())

</pre></blockquote>

<P>

<DD><DL>

<DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></CODE></DL>

</DD>

<DD><DL>

<DT><B>Returns:</B><DD>a string representation of the object. 该对象的字符串形式。</DL>

</DD>

</DL>

<!-- ========= END OF CLASS DATA ========= -->

<HR>

<!-- ======= START OF BOTTOM NAVBAR ====== -->

<A NAME="navbar_bottom"><!-- --></A>

<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>

<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">

<TR>

<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">

<A NAME="navbar_bottom_firstrow"><!-- --></A>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">

<TR ALIGN="center" VALIGN="top">

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/NetworkInterface.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>

<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>

</TR>

</TABLE>

</TD>

<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>

<b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.4.2</b></EM>

</TD>

</TR>

<TR>

<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">

&nbsp;<A HREF="../../java/net/NetPermission.html" title="class in java.net"><B>PREV CLASS</B></A>&nbsp;

&nbsp;<A HREF="../../java/net/PasswordAuthentication.html" title="class in java.net"><B>NEXT CLASS</B></A></FONT></TD>

<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">

<A HREF="../../index.html" target="_top"><B>FRAMES</B></A> &nbsp;

&nbsp;<A HREF="NetworkInterface.html" target="_top"><B>NO FRAMES</B></A> &nbsp;

&nbsp;<SCRIPT type="text/javascript">

<!--

if(window==top) {

document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');

}

//-->

</SCRIPT>

<NOSCRIPT>

<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>

</NOSCRIPT>

</FONT></TD>

</TR>

<TR>

<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">

SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>

<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">

DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>

</TR>

</TABLE>

<A NAME="skip-navbar_bottom"></A>

<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>

<font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="../../../relnotes/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="../../../relnotes/license.html">license terms</a>. Also see the <a href="http://java.sun.com/docs/redist.html">documentation redistribution policy</a>.</font>

</BODY>

</HTML>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有