Java return map entry

Java return map entry

A map entry (key-value pair). The Map.entrySet method returns a collection-view of the map, whose elements are of this class. The only way to obtain a reference to a map entry is from the iterator of this collection-view. These Map.Entry objects are valid only for the duration of the iteration; more formally, the behavior of a map entry is undefined if the backing map has been modified after the entry was returned by the iterator, except through the setValue operation on the map entry.

Method Summary

Method Detail

getKey

getValue

Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator’s remove operation), the results of this call are undefined.

setValue

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator’s remove operation).

equals

Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries represent the same mapping. More formally, two entries e1 and e2 represent the same mapping if

(e1.getKey()==null ? e2.getKey()==null : e1.getKey().equals(e2.getKey())) && (e1.getValue()==null ? e2.getValue()==null : e1.getValue().equals(e2.getValue()))

This ensures that the equals method works properly across different implementations of the Map.Entry interface.

Читайте также:  Date format with timestamp in php

hashCode

(e.getKey()==null ? 0 : e.getKey().hashCode()) ^ (e.getValue()==null ? 0 : e.getValue().hashCode())

This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2 , as required by the general contract of Object.hashCode .

comparingByKey

static Comparable,​V> ComparatorMap.Entry> comparingByKey()

Returns a comparator that compares Map.Entry in natural order on key. The returned comparator is serializable and throws NullPointerException when comparing an entry with a null key.

comparingByValue

static Comparable> ComparatorMap.Entry> comparingByValue()

Returns a comparator that compares Map.Entry in natural order on value. The returned comparator is serializable and throws NullPointerException when comparing an entry with null values.

comparingByKey

static ComparatorMap.Entry> comparingByKey​(Comparator cmp)

Returns a comparator that compares Map.Entry by key using the given Comparator . The returned comparator is serializable if the specified comparator is also serializable.

comparingByValue

static ComparatorMap.Entry> comparingByValue​(Comparator cmp)

Returns a comparator that compares Map.Entry by value using the given Comparator . The returned comparator is serializable if the specified comparator is also serializable.

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Java return map entry

Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).

Provides classes for reading and writing the JAR (Java ARchive) file format, which is based on the standard ZIP file format with an optional manifest file.

The scripting API consists of interfaces and classes that define Java TM Scripting Engines and provides a framework for their use in Java applications.

Uses of Map.Entry in java.awt

Methods in java.awt that return types with arguments of type Map.Entry
Modifier and Type Method and Description
Set> RenderingHints. entrySet ()

Uses of Map.Entry in java.security

Methods in java.security that return types with arguments of type Map.Entry
Modifier and Type Method and Description
Set> Provider. entrySet ()

Uses of Map.Entry in java.util

Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.

Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.

Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.

Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.

Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.

Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.

Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.

Uses of Map.Entry in java.util.concurrent

Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such entry.

Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.

Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.

Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.

Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.

Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.

Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.

Returns the result of accumulating all entries using the given reducer to combine values, or null if none.

Returns the result of accumulating all entries using the given reducer to combine values, or null if none.

Returns the result of accumulating all entries using the given reducer to combine values, or null if none.

Returns the result of accumulating all entries using the given reducer to combine values, or null if none.

Returns the result of accumulating the given transformation of all entries using the given reducer to combine values, or null if none.

Returns the result of accumulating the given transformation of all entries using the given reducer to combine values, and the given basis as an identity value.

Returns the result of accumulating the given transformation of all entries using the given reducer to combine values, and the given basis as an identity value.

Returns the result of accumulating the given transformation of all entries using the given reducer to combine values, and the given basis as an identity value.

Uses of Map.Entry in java.util.jar

Methods in java.util.jar that return types with arguments of type Map.Entry
Modifier and Type Method and Description
Set> Attributes. entrySet ()

Uses of Map.Entry in javax.management.openmbean

Methods in javax.management.openmbean that return types with arguments of type Map.Entry
Modifier and Type Method and Description
Set> TabularDataSupport. entrySet ()

Returns a collection view of the index to row mappings contained in this TabularDataSupport instance.

Uses of Map.Entry in javax.script

Methods in javax.script that return types with arguments of type Map.Entry
Modifier and Type Method and Description
Set> SimpleBindings. entrySet ()

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Источник

Оцените статью