FIND YOUR NEXT FEW LINES

Results for “Java”

Small, practical examples. Search by task or narrow things down below.

257 snippets foundClear filters
JavaScriptArray restructuring

Generate a bounded integer range

JavaScript: Array.from supplies each output position to its mapping function.

JavaScript✓ Tested
JavaDates & time zones

Generate a half-open range of dates

Java: datesUntil includes the starting date and excludes the end date.

Java✓ Tested
JavaScriptObject behavior & collections

Group records into map entries

JavaScript: Initialize an array for a missing Map key before appending its values.

JavaScript✓ Tested
JavaStream transformations

Group strings by their length

Java: Choose a TreeMap supplier when group keys must have deterministic order.

Java✓ Tested
JavaGetting Started

Handle three possible outcomes

Java: Check high, normal and low values with an ordered conditional chain.

Java✓ Tested
JavaScriptGetting Started

Handle three possible outcomes

JavaScript: Check high, normal and low values with an ordered conditional chain.

JavaScript✓ Tested
JavaStream transformations

Index records by a unique key

Java: Use toMap with an explicit merge rule so duplicate keys have defined behavior.

Java✓ Tested
JavaQueues & collection operations

Initialize a map entry only when absent

Java: Use computeIfAbsent when creating a collection for a new key.

Java✓ Tested
JavaScriptPromises & iteration protocols

Inspect both successful and failed promise results

JavaScript: allSettled preserves input order and reports failures without rejecting the combined promise.

JavaScript✓ Tested
JavaEncoding & structured values

Inspect components of a URI

Java: Use URI parsing instead of splitting a URL at punctuation manually.

Java✓ Tested
JavaScriptRegular expressions & URL encoding

Inspect the parsed pieces of a URL

JavaScript: Use URL properties rather than splitting a URL at punctuation.

JavaScript✓ Tested
JavaScriptObjects & JSON

Iterate over object entries

Read JavaScript property names and values using Object.entries.

JavaScript✓ Tested