YouTip LogoYouTip

Number Equals

Java equals() Method | Tutorial

Tutorial -- Learning is not just about technology, but also about dreams!

Java Tutorial

Java Tutorial Java Introduction Java Development Environment Setup Java Basic Syntax Java Comments Java Objects and Classes Java Basic Data Types Java Variable Types Java Variable Naming Rules Java Modifier Types Java Operators Java Loop Structures – for, while and do…while Java Conditional Statements – if…else Java switch case Statement Java Number & Math Class Java Character Class Java String Class Java StringBuffer and StringBuilder Class Java Arrays Java Date and Time Java Regular Expressions Java Methods Java Constructors Java Stream, File, and IO Java Scanner Class Java Exception Handling

Java Object-Oriented

Java Inheritance Java Override/Overload Java Polymorphism Java Abstraction Java Encapsulation Java Interfaces Java Enums Java Package Java Reflection

Java Advanced Tutorial

Java Data Structures Java Collections Framework Java ArrayList Java LinkedList Java HashSet Java HashMap Java Iterator Java Object Java NIO Files Java Generics Java Serialization Java Networking Java Sending Email Java Multithreading Java Applet Basics Java Documentation Comments Java Examples Java 8 New Features Java MySQL Connection Java 9 New Features Java Quiz Java Common Libraries

Java switch case Statement

Java Character Class

Java equals() Method

Java Number Class Java Number Class


The equals() method is used to determine whether a Number object is equal to the method's parameter.

Syntax

public boolean equals(Object o)

Parameters

o -- Any object.

Return Value

If the Number object is not null, and its type and numerical value are both equal to the method's parameter, it returns True; otherwise, it returns False.

Double and Float objects have some additional conditions. You can refer to the API manual: JDK 1.6.

Example

Example

public class Test{
    public static void main(String args[]){
        Integer x = 5;
        Integer y = 10;
        Integer z = 5;
        Short a = 5;
        System.out.println(x.equals(y));
        System.out.println(x.equals(z));
        System.out.println(x.equals(a));
    }
}

Compile the above program, the output result is:

false
true
false

Java Number Class Java Number Class

Java switch case Statement

Java Character Class

iFlytek Xingchen Coding Plan includes free model call quota, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform. Configuration Guide Β₯3.9/month Subscribe Now

Click to Share Notes

Cancel

Write notes...

Image URL

Image Description

Image Size Γ—

Share Notes

  • Nickname (Required)
  • Email (Required)
  • Reference URL

Category Navigation

← Number TostringNumber Xxxvalue β†’