Java guides
Every published Java guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Java guides
Most readLatest Java guides
Page 25 of 109Java 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.
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.
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.
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.
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.
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 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.
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.
Java Math.round: How to Round Numbers Correctly
Understand how Math.round works in Java, including tie-breaking, negative numbers, and when to use BigDecimal for precise rounding.
Java Math sqrt: Calculating Square Roots in Java
A practical guide to Java's Math.sqrt method: syntax, return behavior for negative and NaN inputs, precision concerns, and alternatives such as BigDecimal.sqrt.