Browse by Topic

Popular

Latest

Latest Java Posts

A Java BigDecimal object representing precise decimal arithmetic with a scale and rounding mode, illustrating financial calculations.
Java

Java BigDecimal: Precision, Rounding, and Performance

How to use Java BigDecimal for exact decimal arithmetic, including construction, rounding, comparison, and performance tradeoffs.

BigDecimalJavaPrecisionRounding
A visual metaphor for Java BigInteger showing a large number expanding beyond the limits of a long primitive type, with a magnifying lens and a Java-style code segment.
Java

Java BigInteger: Arbitrary-Precision Arithmetic

java biginteger: Understand Java BigInteger for arbitrary-precision arithmetic: creation, operations, conversions, performance tradeoffs, and common pitfalls.

BigIntegerJavaArbitrary PrecisionNumeric Types
Illustration comparing java.util.Random and ThreadLocalRandom for concurrent Java applications
Java

Java Random vs ThreadLocalRandom Comparison

Compare java.util.Random and ThreadLocalRandom in Java: how contention, thread safety, seeding, and API usage affect concurrency, and how to choose between them.

JavaRandomThreadLocalRandomConcurrency
SecureRandom class generating random bytes with a shield representing security
Java

Java Secure Random: Using SecureRandom Instead of Random

This article explains how to generate secure random values in Java with SecureRandom: seeding, thread safety, performance, and when to use it instead of Random.

SecureRandomJava SecurityRandom Number GenerationCryptography
Illustration of ThreadLocalRandom providing per-thread random number generators in parallel lanes without shared state contention
Java

Java ThreadLocalRandom: Contention-Free Random Numbers

See how Java ThreadLocalRandom uses per-thread seed state to avoid contention, with code examples for bounded generation, primitive streams, and edge cases.

ThreadLocalRandomJava ConcurrencyRandom Number Generationjava.util.concurrent
Illustration of Java random number generation within a range, showing a number line with bounds and a random value.
Java

Java Random Range: Generate Integers in a Range

Learn how to generate random integers in a range in Java using Random, ThreadLocalRandom, SecureRandom, and the RandomGenerator interface.

javarandomThreadLocalRandomSecureRandom
Illustration of Java Random nextInt generating a random integer within a specified range.
Java

Java Random nextInt: Usage, Bounds, and Thread Safety

java random nextint: Learn how to use Java's Random.nextInt() correctly, including range generation, bound handling, thread safety, and performance tradeoffs.

JavaRandomnextIntThreadLocalRandom
Illustration of Java's Random class showing a seed input and multiple output streams, with a thread-safety indicator and alternatives.
Java

Java Random Class: Usage, Seeding, and Thread Safety

Learn how to use Java's Random class correctly: constructors, methods, seeding for reproducible tests, thread safety, and when to choose ThreadLocalRandom or SecureRandom.

java.util.RandomThreadLocalRandomSecureRandomrandom number generation
Java code snippet showing Math.random() usage with a dice roll example, illustrating random number generation.
Java

Java Math.random(): Generating Random Numbers in Java

Learn how to use Java's Math.random() to generate random doubles and integers, avoid off-by-one errors, and choose between Random, ThreadLocalRandom, and SecureRandom.

Math.randomRandom numbersJava Random classThreadLocalRandom
Diagram showing Math.ceil rounding up and Math.floor rounding down on a number line
Java

Java Math.ceil and Math.floor: Rounding Direction Explained

Understand how Java's Math.ceil and Math.floor round doubles, including negative-number behavior, edge cases, and code examples for choosing the right method.

Math.ceilMath.floorroundingfloating-point