AtomicReference: reading, identity-based CAS, and swapping
Read the current reference, replace it only when it matches the expected reference by identity, or swap it unconditionally and get the previous configuration back.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Read the current reference, replace it only when it matches the expected reference by identity, or swap it unconditionally and get the previous configuration back.
`AutoCloseable.close()` releases a resource. Call it on an object yourself, or let `try-with-resources` call it automatically when the block exits.
The java.util.Base64 class represents bytes as Base64 text and recovers them by decoding. Learn the Basic variant, explicit UTF-8 conversion, and handling of malformed input.
Use `java.util.Base64` to represent bytes as text and recover the original bytes. Base64 is reversible and provides neither confidentiality nor integrity.
Add BigDecimal values exactly, or use MathContext to set the precision and rounding mode of the result.
`BigDecimal.compareTo` compares numeric values without treating different scales as different values. Test its result against zero for ordering or numeric equality.
Use this `divide` overload to set the quotient’s scale and choose a rounding rule. The result has the requested scale even when the division is exact.
Read decimal text without converting through `double`, calculate exactly, choose a scale and rounding rule, and compare numbers independently of their scale.
Multiply two `BigDecimal` values exactly, or round the product using the precision and rounding mode specified by a `MathContext`.
Set the scale of a `BigDecimal` while preserving its value or explicitly choosing how to round. The call does not change the original object.
Subtract two `BigDecimal` values exactly, or round the difference using a `MathContext`. Neither operand changes.
Use `toPlainString()` to write a `BigDecimal` without exponent notation. Parsing the resulting text restores the numeric value, but not always the original scale.
Learn the three `BigDecimal.valueOf` overloads in Java 21 and why converting a `double` with the factory can differ from passing it to the constructor.
Choose between immediate operations, timed waits, and waits with no timeout. Learn how to inspect the queue and why its head is not always the oldest item.
Get an independent copy of the bytes written in memory and learn why this stream remains usable after `close()`.
Write six bytes into a 32-byte direct buffer and see how `flip()`, `compact()`, and `clear()` change the range available for reading or writing.
Wrap an existing byte array without copying it, distinguish capacity from limit, and read a byte at a chosen index without moving the buffer’s position.
ByteOrder describes the byte ordering of multibyte values. Learn the difference between BIG_ENDIAN and LITTLE_ENDIAN and how to select data interpretation explicitly in ByteBuffer.
Character.charCount(int codePoint) returns the number of char units needed to represent a code point in UTF-16: either 1 or 2. The method does not validate its argument, so its result does not establish that a value is a Unicode code point.
CharacterCodingException is a checked exception in java.nio.charset that extends IOException. It signals a failure when converting between characters and bytes and provides a common catch type for malformed input and unmappable characters.
Check whether one Unicode code point is a letter, even when its UTF-16 representation takes two `char` code units.
This method returns a single `char`. Use it to uppercase the first UTF-16 code unit of a string, not to uppercase an arbitrary Unicode code point or a whole grapheme.
Drain the actual bytes returned by a UTF-8 encoder, then inspect the consumed CharBuffer through a read-only view with its own cursor.
Convert windows-1250 bytes to UTF-8 by decoding them into Unicode characters and then encoding those characters again. Choose how the decoder handles each kind of error.