public final class AvgOf extends Number
Here is how you can use it to fine mathematical average of numbers:
int sum = new AvgOf(1, 2, 3, 4).intValue(); long sum = new AvgOf(1L, 2L, 3L).longValue(); int sum = new AvgOf(numbers.toArray(new Integer[numbers.size()])).intValue();
This class implements Scalar
, which throws a checked
Exception
. This may not be convenient in many cases. To make
it more convenient and get rid of the checked exception you can
use UncheckedScalar
or IoCheckedScalar
decorators.
There is no thread-safety guarantee.
Constructor and Description |
---|
AvgOf(Double... src)
Ctor.
|
AvgOf(Float... src)
Ctor.
|
AvgOf(Integer... src)
Ctor.
|
AvgOf(Iterable<Scalar<Number>> src)
Ctor.
|
AvgOf(Long... src)
Ctor.
|
AvgOf(Scalar<Number>... src)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
double |
doubleValue() |
float |
floatValue() |
int |
intValue() |
long |
longValue() |
byteValue, shortValue
public AvgOf(Integer... src)
src
- Numberspublic AvgOf(Long... src)
src
- Numberspublic AvgOf(Double... src)
src
- Numberspublic AvgOf(Float... src)
src
- Numbers@SafeVarargs public AvgOf(Scalar<Number>... src)
src
- Numberspublic float floatValue()
floatValue
in class Number
public double doubleValue()
doubleValue
in class Number
Copyright © 2017 Cactoos. All rights reserved.