當前位置: 首頁>>代碼示例>>Java>>正文


Java InterfaceAddress.equals方法代碼示例

本文整理匯總了Java中java.net.InterfaceAddress.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java InterfaceAddress.equals方法的具體用法?Java InterfaceAddress.equals怎麽用?Java InterfaceAddress.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.InterfaceAddress的用法示例。


在下文中一共展示了InterfaceAddress.equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.net.InterfaceAddress; //導入方法依賴的package包/類
public static void main(String[] args) {
    InterfaceAddress ia1;
    InterfaceAddress ia2;
    InetAddress loopbackAddr = InetAddress.getLoopbackAddress();
    InetAddress broadcast1 = null;
    InetAddress broadcast2 = null;

    try {
        broadcast1 = InetAddress.getByName("255.255.255.0");
        broadcast2 = InetAddress.getByName("255.255.0.0");
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }

    ia1 = createInterfaceAddress(loopbackAddr, (InetAddress) null, (short)45);
    ia2 = createInterfaceAddress(loopbackAddr, (InetAddress) null, (short)45);

    compare(ia1, ia2, true);

    ia2 = createInterfaceAddress(loopbackAddr, broadcast1, (short)45);
    compare(ia1, ia2, false);

    ia2 = createInterfaceAddress((InetAddress)null, broadcast1, (short)45);
    compare(ia1, ia2, false);

    ia1 = createInterfaceAddress(loopbackAddr, broadcast2, (short)45);
    ia2 = createInterfaceAddress(loopbackAddr, broadcast2, (short)45);
    compare(ia1, ia2, true);

    ia1.equals(null);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:32,代碼來源:Equals.java

示例2: compare

import java.net.InterfaceAddress; //導入方法依賴的package包/類
static void compare(InterfaceAddress ia1, InterfaceAddress ia2, boolean equal) {
    if (ia1.equals(ia2) != equal)
        throw new RuntimeException("Failed: " + ia1 + " not equals to " + ia2);

    if (ia2.equals(ia1) != equal)
        throw new RuntimeException("Failed: " + ia2 + " not equals to " + ia1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:Equals.java


注:本文中的java.net.InterfaceAddress.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。