1perator overloading is the ability to redefine the functionality of the operators. Programming languages like c++ supports operator overloading
1class CalculateSquare
2 {
3public void square()
4 {
5System.out.println("No Parameter Method Called");
6 }
7public int square( int number )
8 {
9int square = number * number;
10System.out.println("Method with Integer Argument Called:"+square);
11}
12public float square( float number )
13{
14 float square = number * number;
15 System.out.println("Method with float Argument Called:"+square);
16}
17public static void main(String[] args)
18 {
19 CalculateSquare obj = new CalculateSquare();
20 obj.square();
21 obj.square(5);
22 obj.square(2.5);
23 }
24 }
25
1Java doesn't support user-defined operator overloading. The only aspect
2of Java which comes close to "custom" operator overloading is the handling of
3+ for strings