Java Identity to String identityToString(Object obj)

Here you can find the source of identityToString(Object obj)

Description

Returns a string value of an object similar to that returned by Object.toString().

License

Apache License

Declaration

public static String identityToString(Object obj) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    /**/*from ww  w .ja v  a 2s.c  om*/
     *  Returns a string value of an object similar to that returned by <code>
     *  Object.toString()</code>. The primary difference is that the numeric
     *  part of the string is its identity hashcode, and it's in decimal (so as
     *  not to be confused with the default <code>toString()</code>).
     *  <p>
     *  This method is null-safe: if passed <code>null</code>, it returns
     *  "null".
     */
    public static String identityToString(Object obj) {
        return (obj == null) ? "null" : obj.getClass().getName() + "@" + System.identityHashCode(obj);
    }
}

Related

  1. identityToString(final Object o)
  2. identityToString(final Object obj)
  3. identityToString(Object obj)
  4. identityToString(Object obj)
  5. identityToString(Object pObject)
  6. identityToString(StringBuffer buffer, Object object)