FIND YOUR NEXT FEW LINES

Results for “Java”

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

257 snippets foundClear filters
JavaScriptArrays

Remove duplicate values

Use a JavaScript Set to preserve the first occurrence of each primitive value.

JavaScript✓ Tested
JavaScriptRegular expressions & URL encoding

Reorder captured text in a replacement

JavaScript: Use numbered replacement groups to rearrange a known two-part name.

JavaScript✓ Tested
JavaGetting Started

Repeat a fixed number of times

Java: Use a counted loop to print three numbered steps.

Java✓ Tested
JavaScriptGetting Started

Repeat a fixed number of times

JavaScript: Use a counted loop to print three numbered steps.

JavaScript✓ Tested
JavaScriptText handling & Unicode

Repeat a string a fixed number of times

JavaScript: String.repeat requires a nonnegative finite repetition count.

JavaScript✓ Tested
JavaText validation & formatting

Repeat text a fixed number of times

Java: Use String.repeat with a nonnegative repetition count.

Java✓ Tested
JavaGetting Started

Repeat while a condition holds

Java: Count down while a positive number remains, updating the loop variable on each iteration.

Java✓ Tested
JavaScriptGetting Started

Repeat while a condition holds

JavaScript: Count down while a positive number remains, updating the loop variable on each iteration.

JavaScript✓ Tested
JavaScriptStrings

Replace all literal matches

Replace repeated substrings with JavaScript replaceAll.

JavaScript✓ Tested
JavaScriptArray restructuring

Replace an array segment in place

JavaScript: splice returns removed items and inserts replacements at the chosen position.

JavaScript✓ Tested
JavaStrings

Replace literal text

Replace all literal matches in a Java string without regular expressions.

Java✓ Tested
JavaGetting Started

Replace one collection element

Java: Update an existing element at a known valid index.

Java✓ Tested