Returns the string representation of this Hashtable. @return the string representation of this Hashtable.
()
| 861 | * @return the string representation of this {@code Hashtable}. |
| 862 | */ |
| 863 | @Override |
| 864 | public synchronized String toString() { |
| 865 | if (isEmpty()) { |
| 866 | return "{}"; //$NON-NLS-1$ |
| 867 | } |
| 868 | |
| 869 | StringBuilder buffer = new StringBuilder(size() * 28); |
| 870 | buffer.append('{'); |
| 871 | for (int i = lastSlot; i >= firstSlot; i--) { |
| 872 | Entry<K, V> entry = elementData[i]; |
| 873 | while (entry != null) { |
| 874 | if (entry.key != this) { |
| 875 | buffer.append(entry.key); |
| 876 | } else { |
| 877 | // luni.04=this Map |
| 878 | buffer.append("(" + Messages.getString("luni.04") + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ |
| 879 | } |
| 880 | buffer.append('='); |
| 881 | if (entry.value != this) { |
| 882 | buffer.append(entry.value); |
| 883 | } else { |
| 884 | // luni.04=this Map |
| 885 | buffer.append("(" + Messages.getString("luni.04") + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ |
| 886 | } |
| 887 | buffer.append(", "); //$NON-NLS-1$ |
| 888 | entry = entry.next; |
| 889 | } |
| 890 | } |
| 891 | // Remove the last ", " |
| 892 | if (elementCount > 0) { |
| 893 | buffer.setLength(buffer.length() - 2); |
| 894 | } |
| 895 | buffer.append('}'); |
| 896 | return buffer.toString(); |
| 897 | } |
| 898 | |
| 899 | /** |
| 900 | * Returns a collection of the values contained in this {@code Hashtable}. |