You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Map에서 Key가 존재하면 해당 Key의 Value를, 존재하지 않으면 기본값(defaultValue)를 반환
/** * Returns the value to which the specified key is mapped, or * {@code defaultValue} if this map contains no mapping for the key. * * @implSpec * The default implementation makes no guarantees about synchronization * or atomicity properties of this method. Any implementation providing * atomicity guarantees must override this method and document its * concurrency properties. * * @param key the key whose associated value is to be returned * @param defaultValue the default mapping of the key * @return the value to which the specified key is mapped, or * {@code defaultValue} if this map contains no mapping for the key * @throws ClassCastException if the key is of an inappropriate type for * this map * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>) * @throws NullPointerException if the specified key is null and this map * does not permit null keys * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>) * @since 1.8 */defaultVgetOrDefault(Objectkey, VdefaultValue) {
Vv;
return (((v = get(key)) != null) || containsKey(key))
? v
: defaultValue;
}
Map<Object, Integer> words = newHashMap<>();
// ch가 존재하면 해당 ch의 값에 + 1 을, 존재하지 않으면 1을 저장words.put(ch, words.getOrDefault(ch, 0) + 1);
Map.getOrDefault(Object key, V defaultValue)
정규표현식(RegExp)
Integer List to int Array
The text was updated successfully, but these errors were encountered: