當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java SimpleTimeZone hashCode()用法及代碼示例


SimpleTimeZone類的hashCode()方法為SimpleDateFormat對象生成哈希碼。

用法:

public int hashCode()

參數:該函數不接受任何參數。


返回值:它返回該對象的哈希碼。

異常:該函數不會引發任何異常。

下麵的程序演示了上述函數:

示例1:

// program to demonstrate the 
// function java.util.SimpleTimeZone.hashCode() 
  
import java.util.*; 
  
public class GFG { 
  
    public static void main(String[] args) 
    { 
  
        // create simple time zone object 
        SimpleTimeZone obj 
            = new SimpleTimeZone(500, "US"); 
  
        System.out.println("SimpleTimeZone = "
                           + obj); 
  
        // get hash code value and print 
        System.out.println("Hash code is = "
                           + obj.hashCode()); 
    } 
}
輸出:
SimpleTimeZone: java.util.SimpleTimeZone
[ 
 id=US,
 offset=500,
 dstSavings=3600000,
 useDaylight=false,
 startYear=0,
 startMode=0,
 startMonth=0,
 startDay=0,
 startDayOfWeek=0,
 startTime=0,
 startTimeMode=0,
 endMode=0,
 endMonth=0,
 endDay=0,
 endDayOfWeek=0,
 endTime=0,
 endTimeMode=0
]
Hash code is = 500

示例2:

// program to demonstrate the 
// function java.util.SimpleTimeZone.hashCode() 
  
import java.util.*; 
  
public class GFG { 
  
    public static void main(String[] args) 
    { 
  
        // create simple time zone object 
        SimpleTimeZone obj 
            = new SimpleTimeZone(500, "IN"); 
  
        System.out.println("SimpleTimeZone: "
                           + obj); 
  
        // get hash code value and print 
        System.out.println("Hash code is = "
                           + obj.hashCode()); 
    } 
}
輸出:
SimpleTimeZone: java.util.SimpleTimeZone
[ 
 id=IN,
 offset=500,
 dstSavings=3600000,
 useDaylight=false,
 startYear=0,
 startMode=0,
 startMonth=0,
 startDay=0,
 startDayOfWeek=0,
 startTime=0,
 startTimeMode=0,
 endMode=0,
 endMonth=0,
 endDay=0,
 endDayOfWeek=0,
 endTime=0,
 endTimeMode=0
]
Hash code is = 500


相關用法


注:本文由純淨天空篩選整理自Twinkl Bajaj大神的英文原創作品 SimpleTimeZone hashCode() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。