- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Format Specifier for Hash Code in Java
Format specifier for Hash Code us %h.
Firstly, create a new object for Formatter and Calendar −
Formatter f = new Formatter(); Calendar c = Calendar.getInstance();
For hash code −
f.format("%h", c)
The following is an example that finds the hash code −
Example
import java.util.Calendar; import java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); Calendar c = Calendar.getInstance(); System.out.println("Hash Code: "+f.format("%h", c)); } }
Output
Hash Code: 4b899958
- Related Articles
- Get Hash Code for Integer in Java
- Obtain the hash code for a string in Java
- Get the hash code for this instance in C#
- Sortable ("s") Format Specifier in C#
- C# Exponential (“E”) Format Specifier
- C# Percent ("P") Format Specifier
- Short Date ("d") Format Specifier
- C# Currency ("C") Format Specifier
- C# Numeric (“N”) Format Specifier
- C# Decimal ("D") Format Specifier
- C# Hexadecimal ("X") Format Specifier
- Year Month ("Y") Format Specifier in C#
- Long Date ("D") Format Specifier in C#
- The "0" custom format specifier in C#
- Month ("M", "m") Format Specifier in C#

Advertisements