android中运算符重载对应的指定函数集合
在Android中,运算符重载是通过重写相应的方法来实现的。以下是一些常见的运算符和对应的方法集合:
-
一元运算符:
- 一元加法运算符(+):重写
public T unaryPlus()方法。 - 一元减法运算符(-):重写
public T unaryMinus()方法。 - 逻辑非运算符(!):重写
public T not()方法。
- 一元加法运算符(+):重写
-
二元运算符:
- 加法运算符(+):重写
public T plus(T other)方法。 - 减法运算符(-):重写
public T minus(T other)方法。 - 乘法运算符(*):重写
public T times(T other)方法。 - 除法运算符(/):重写
public T div(T other)方法。 - 取模运算符(%):重写
public T rem(T other)方法。 - 相等运算符(==):重写
public boolean equals(Object other)方法。 - 不等运算符(!=):重写
public boolean notEquals(Object other)方法。 - 大于运算符(>):重写
public boolean greaterThan(T other)方法。 - 小于运算符(<):重写
public boolean lessThan(T other)方法。 - 大于等于运算符(>=):重写
public boolean greaterThanOrEqual(T other)方法。 - 小于等于运算符(<=):重写
public boolean lessThanOrEqual(T other)方法。
- 加法运算符(+):重写
-
赋值运算符:
- 等号赋值运算符(=):重写
public void setValue(T value)方法。
- 等号赋值运算符(=):重写
这只是一些常见的运算符和对应的方法集合,具体的重载方法可以根据需要进行扩展
原文地址: https://www.cveoy.top/t/topic/ivW1 著作权归作者所有。请勿转载和采集!