Returns the string representation of this Hashtable. @return the string representation of this Hashtable.
()
| 825 | * @return the string representation of this {@code Hashtable}. |
| 826 | */ |
| 827 | @Override |
| 828 | public synchronized String toString() { |
| 829 | if (isEmpty()) { |
| 830 | return "{}"; //$NON-NLS-1$ |
| 831 | } |
| 832 | |
| 833 | StringBuffer buffer = new StringBuffer(size() * 28); |
| 834 | buffer.append('{'); |
| 835 | for (int i = lastSlot; i >= firstSlot; i--) { |
| 836 | Entry<K, V> entry = elementData[i]; |
| 837 | while (entry != null) { |
| 838 | if (entry.key != this) { |
| 839 | buffer.append(entry.key); |
| 840 | } else { |
| 841 | // luni.04=this Map |
| 842 | buffer.append("(this)"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ |
| 843 | } |
| 844 | buffer.append('='); |
| 845 | if (entry.value != this) { |
| 846 | buffer.append(entry.value); |
| 847 | } else { |
| 848 | // luni.04=this Map |
| 849 | buffer.append("(this)"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ |
| 850 | } |
| 851 | buffer.append(", "); //$NON-NLS-1$ |
| 852 | entry = entry.next; |
| 853 | } |
| 854 | } |
| 855 | // Remove the last ", " |
| 856 | if (elementCount > 0) { |
| 857 | buffer.setLength(buffer.length() - 2); |
| 858 | } |
| 859 | buffer.append('}'); |
| 860 | return buffer.toString(); |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * Returns a collection of the values contained in this {@code Hashtable}. |