what is operator overloading in java
perator overloading is the ability to redefine the functionality of the operators. Programming languages like c++ supports operator overloading
what is operator overloading in java
perator overloading is the ability to redefine the functionality of the operators. Programming languages like c++ supports operator overloading
java overloading
class CalculateSquare
{
public void square()
{
System.out.println("No Parameter Method Called");
}
public int square( int number )
{
int square = number * number;
System.out.println("Method with Integer Argument Called:"+square);
}
public float square( float number )
{
float square = number * number;
System.out.println("Method with float Argument Called:"+square);
}
public static void main(String[] args)
{
CalculateSquare obj = new CalculateSquare();
obj.square();
obj.square(5);
obj.square(2.5);
}
}
overloading + operator in java
Java doesn't support user-defined operator overloading. The only aspect
of Java which comes close to "custom" operator overloading is the handling of
+ for strings
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us