Results for “Java”
Small, practical examples. Search by task or narrow things down below.
Iterate with array indices and values
JavaScript: entries provides each position and value without a separate counter.
JavaScript✓ Tested
Join strings with a separator
Build a Java string from several values using String.join.
Java✓ Tested
Join transformed stream values
Java: Use Collectors.joining after converting elements to strings.
Java✓ Tested
Keep both matching and rejected values
JavaScript: Use two explicit outputs when a caller needs both sides of a classification.
JavaScript✓ Tested
List an object’s own enumerable keys
JavaScript: Object.keys omits inherited and non-enumerable properties.
JavaScript✓ Tested
List regular files
List immediate regular files in sorted order and close the Java directory stream.
Java✓ Tested
Load a small properties configuration
Java: Use a Reader to make the configuration character encoding explicit.
Java✓ Tested
Locate a value in a sorted array
Java: Use Arrays.binarySearch only after establishing ascending order.
Java✓ Tested
Map items to multiple output values
JavaScript: flatMap combines mapping and a one-level flattening operation.
JavaScript✓ Tested
Measure a duration between instants
Java: Use Duration for elapsed timeline time and retrieve total seconds.
Java✓ Tested
Measure a short text value
Java: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
Java✓ Tested
Measure a short text value
JavaScript: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
JavaScript✓ Tested