FIND YOUR NEXT FEW LINES

Results for “Java”

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

257 snippets foundClear filters
JavaStream transformations

Find the first matching stream value

Java: Use findFirst and an explicit default for an empty result.

Java✓ Tested
JavaPrecise numeric calculations

Find the greatest common divisor

Java: BigInteger.gcd calculates an exact nonnegative common divisor.

Java✓ Tested
JavaDates & time zones

Find the last day of a month

Java: Use YearMonth so leap years and month lengths are handled by the calendar library.

Java✓ Tested
JavaDates & time zones

Find the next chosen weekday

Java: TemporalAdjusters.next excludes the starting day even if it already has that weekday.

Java✓ Tested
JavaScriptArray traversal & selection

Find the position of a matching item

JavaScript: findIndex returns -1 when the predicate matches nothing.

JavaScript✓ Tested
JavaGetting Started

Find what remains after division

Java: Use the remainder operator to count items left after forming complete groups.

Java✓ Tested
JavaScriptGetting Started

Find what remains after division

JavaScript: Use the remainder operator to count items left after forming complete groups.

JavaScript✓ Tested
JavaScriptArray restructuring

Flatten a single nesting level

JavaScript: flat defaults to a depth of one and creates a new array.

JavaScript✓ Tested
JavaStream transformations

Flatten nested collections

Java: Use flatMap to concatenate nested Java lists into one stream.

Java✓ Tested
JavaNumbers & dates

Format a decimal number

Format a Java decimal with two digits and a fixed locale.

Java✓ Tested
JavaScriptFiles & async

Format an ISO date

Format a UTC JavaScript Date deterministically.

JavaScript✓ Tested
JavaScriptUTC date operations

Format whole seconds as hours minutes and seconds

JavaScript: Use integer divisions and remainders for a nonnegative duration.

JavaScript✓ Tested