Results for “Java”
Small, practical examples. Search by task or narrow things down below.
Display a JavaScript value in JSX
Display a JavaScript value in JSX with a small React component and explicit browser behavior.
React✓ Tested
Add calendar days in UTC
JavaScript: Use UTC date setters to cross month boundaries without local daylight-saving effects.
JavaScript✓ Tested
Add days to a date
Parse an ISO date and add calendar days using Java LocalDate.
Java✓ Tested
Append a line
Append text to a Java file, creating it if necessary.
Java✓ Tested
Build a URL query string from values
JavaScript: URLSearchParams handles query escaping and repeated parameter appends.
JavaScript✓ Tested
Build an object from key-value entries
JavaScript: Object.fromEntries converts an iterable of pairs into ordinary own properties.
JavaScript✓ Tested
Build text efficiently in a loop
Java: Append to StringBuilder when constructing a string incrementally.
Java✓ Tested
Calculate a page count with ceiling division
JavaScript: Use Math.ceil for a nonnegative item count and a positive page size.
JavaScript✓ Tested
Calculate a SHA-256 content digest
Java: Hash UTF-8 bytes and format the result as lowercase hexadecimal.
Java✓ Tested
Calculate a simple total
Java: Multiply a unit price by a quantity, then add a delivery fee.
Java✓ Tested
Calculate a simple total
JavaScript: Multiply a unit price by a quantity, then add a delivery fee.
JavaScript✓ Tested
Calculate beyond the long integer range
Java: Use BigInteger when a fixed-width primitive type would overflow.
Java✓ Tested