How to check the type of an object in Java?
Use instanceof for safe type tests, getClass() for the exact runtime class, and pattern matching in Java 16+ and 21+ to test and cast in one step.
2,889 posts about Java: questions with answers, tutorials and articles, newest first.
Use instanceof for safe type tests, getClass() for the exact runtime class, and pattern matching in Java 16+ and 21+ to test and cast in one step.
Java has no typeof operator, but instanceof, getClass() and switch type patterns cover every runtime type check. Examples target Java 21 and later.
Java has eight primitive types: byte, short, int, long, float, double, char and boolean. See sizes, ranges and examples, and how JavaScript primitives differ.
Java has no strict equality operator. Use == for primitives and enums, and equals() for objects, with null-safe and floating-point rules.
Java has eight primitive types and many reference types. See sizes, ranges, default values, autoboxing, var and casting with runnable examples.
Java has eight primitive types and many reference types such as classes, records and arrays. Learn how they differ in storage, comparison and null handling.
A practical comparison of C and Java covering compilation, memory management, pointers, types, error handling, concurrency and when to choose each.

All seven Android activity lifecycle callbacks with Kotlin and Java examples, Logcat order for common actions and state saving advice.
A complete guide to the Android activity lifecycle callbacks, with Kotlin and Java logging examples, Logcat output and how to save state safely.