FIND YOUR NEXT FEW LINES

Results for “Java”

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

257 snippets foundClear filters
JavaEncoding & structured values

Measure UTF-8 bytes separately from characters

Java: Encode a Java string before measuring its serialized byte length.

Java✓ Tested
JavaScriptObjects & JSON

Merge object settings

Use object spread to apply JavaScript overrides to defaults.

JavaScript✓ Tested
JavaFile operations & binary data

Move a file to a new name

Java: Files.move changes the path and returns the destination Path.

Java✓ Tested
JavaGetting Started

Name a value that stays fixed

Java: Use a constant declaration or the language’s constant naming convention for a fixed limit.

Java✓ Tested
JavaScriptGetting Started

Name a value that stays fixed

JavaScript: Use a constant declaration or the language’s constant naming convention for a fixed limit.

JavaScript✓ Tested
JavaRecords & reliable control flow

Narrow an object with a pattern variable

Java: Pattern matching avoids a separate cast after a successful instanceof check.

Java✓ Tested
JavaScriptText handling & Unicode

Normalize identifier case consistently

JavaScript: Use toLowerCase for a simple case-insensitive ASCII identifier lookup.

JavaScript✓ Tested
JavaFile operations & binary data

Normalize relative path components

Java: Path.normalize removes redundant dot components without accessing the filesystem.

Java✓ Tested
JavaScriptStrings

Pad a numeric label

Convert a number to text and pad it to a fixed width.

JavaScript✓ Tested
JavaScriptArray traversal & selection

Pair corresponding array items by position

JavaScript: Validate equal lengths before zipping when missing counterparts would be an error.

JavaScript✓ Tested
JavaDates & time zones

Parse a date with an explicit input pattern

Java: Use DateTimeFormatter for a non-ISO date representation.

Java✓ Tested
JavaEncoding & structured values

Parse a UUID and inspect its version

Java: Use UUID.fromString for a standard UUID value.

Java✓ Tested