Browse by Topic

Popular

Latest

Latest Java Posts

Diagram of Java arithmetic operators with plus, minus, multiply, divide, and modulo symbols over a code editor background.
Java

Java Arithmetic Operators: Syntax, Precedence, and Edge Cases

java arithmetic operators: Understand Java arithmetic operators, including precedence, type promotion, and common edge cases like overflow and division by zero.

arithmetic operatorsJava syntaxoperator precedenceinteger overflow
Illustration of a Java ClassCastException error caused by casting an object to an incompatible type.
Java

Java ClassCastException: Causes and Fixes

Understand why ClassCastException occurs in Java, how type erasure and unchecked casts cause it, and how to prevent it with generics and instanceof.

JavaClassCastExceptionType SafetyGenerics
A branching flow diagram illustrating Java instanceof pattern matching, where a type check binds a variable on one path and rejects the object on the other.
Java

Java instanceof Pattern Matching: Syntax and Scope

Java instanceof pattern matching removes redundant casts. This article explains the syntax, flow scoping rules, record patterns, and pattern matching for switch.

Javainstanceofpattern matchingtype safety
Illustration of the Java instanceof operator checking an object against a type hierarchy with pattern matching binding.
Java

Java instanceof Operator: Syntax and Pattern Matching

Learn how the Java instanceof operator works, including pattern matching, inheritance, null handling, and when to use getClass() or Class.isInstance().

JavainstanceofPattern MatchingType Checking
Diagram showing upcasting from Dog to Animal and downcasting from Animal to Dog with a warning symbol for ClassCastException
Java

Java Upcasting vs Downcasting: Key Differences

java upcasting vs downcasting: Understand Java upcasting vs downcasting: how they work, when to use them, and how to avoid ClassCastException in your code.

JavaType CastingPolymorphismInheritance
Diagram showing an Animal reference being downcast to a Dog subtype in Java with a safety check symbol
Java

Java Downcasting: Syntax, Risks, and Safe Usage

Understand Java downcasting: syntax, when it is safe, the ClassCastException risk, instanceof guards, and pattern matching alternatives for cleaner code.

JavaType CastingInheritanceClassCastException
Diagram showing a Dog object referenced by an Animal variable, illustrating Java upcasting with an arrow from subclass to superclass.
Java

Java Upcasting: Parent Type References Explained

Understand Java upcasting: how a subclass object can be treated as a parent type, what it enables, and where it can limit your code.

upcastinginheritancepolymorphismtype casting
Editorial illustration showing a Java object being cast between parent and child class types with a directional type conversion arrow.
Java

Java Object Casting: Upcasting, Downcasting, and Safety

Learn how Java object casting works: the difference between upcasting and downcasting, when ClassCastException occurs, and how instanceof and pattern matching make type conversion safer.

JavaType CastingClassCastExceptioninstanceof
Diagram showing an integer value 65 becoming the character 'A' with an arrow, highlighting the Java int to char cast.
Java

Java int to char: Conversion and Pitfalls

java int to char: Java int to char conversion involves direct casting, which interprets the int as a Unicode code point. Understand behavior, pitfalls, and when to use...

type conversioncharintegerUnicode
Diagram showing a Java char '7' converting to an integer 7 with a highlighted path, avoiding the ASCII value 55.
Java

Convert java char to int

Learn how to convert a Java char to an int, including digit-value extraction, Unicode behavior, and common pitfalls.

Java conversionASCII valuesnumeric parsingCharacter API