javax.naming.CompositeName類的hashCode()方法用於返回此複合名稱的哈希碼。該複合名稱對象的哈希碼是該複合名稱各個組成部分的“canonicalized”形式的哈希碼總和。
用法:
public int hashCode()
參數:此方法不接受任何內容。
返回值:此方法返回一個表示此名稱的哈希碼的int。
下麵的程序說明CompositeName.hashCode()方法:
程序1:
// Java program to demonstrate
// CompositeName.hashCode()
import java.util.Properties;
import javax.naming.CompositeName;
import javax.naming.InvalidNameException;
public class GFG {
public static void main(String[] args)
throws InvalidNameException
{
// create composite name object
CompositeName CompositeName1
= new CompositeName("a/b/z/y/x");
// apply hashCode()
int hashCode = CompositeName1.hashCode();
// print value
System.out.println("hashCode:" + hashCode);
}
}
輸出:
hashCode:558
程序2:
// Java program to demonstrate
// CompositeName.hashCode() method
import java.util.Properties;
import javax.naming.CompositeName;
import javax.naming.InvalidNameException;
public class GFG {
public static void main(String[] args)
throws InvalidNameException
{
// create composite name object
CompositeName CompositeName1
= new CompositeName("c/e/d/v/a/b/z/y/x/f/j");
// apply hashCode()
int hashCode = CompositeName1.hashCode();
// print value
System.out.println("hashCode:" + hashCode);
}
}
輸出:
hashCode:1184
參考文獻:https://docs.oracle.com/javase/10/docs/api/javax/naming/CompositeName.html#hashCode()
相關用法
- Java CompositeName add()用法及代碼示例
- Java CompositeName get()用法及代碼示例
- Java CompositeName equals()用法及代碼示例
- Java CompositeName isEmpty()用法及代碼示例
- Java CompositeName addAll()用法及代碼示例
- Java CompositeName getPrefix()用法及代碼示例
- Java CompositeName toString()用法及代碼示例
- Java CompositeName clone()用法及代碼示例
- Java CompositeName getSuffix()用法及代碼示例
- Java CompositeName remove()用法及代碼示例
- Java CompositeName getAll()用法及代碼示例
- Java CompositeName toString()用法及代碼示例
- Java CompositeName size()用法及代碼示例
- Java CompositeName compareTo()用法及代碼示例
- Java CompositeName endsWith()用法及代碼示例
注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 CompositeName hashCode() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。