public class Counter extends Number
Obect's methods hashCode() or
equals(), so two counters with the same value are not
necessarily equal.
The value of a counter is stored as an integer. No checks are done in the increment methods to ensure that the results remain within bounds.
| Constructor and Description |
|---|
Counter()
Create a counter with initial count
0. |
Counter(int count)
Create a counter with the specified count value.
|
| Modifier and Type | Method and Description |
|---|---|
double |
doubleValue()
Returns the value of this counter as a double.
|
float |
floatValue()
Returns the value of this counter as a float.
|
void |
increment()
Increments the current count value.
|
void |
increment(int n)
Increment the count value by the specified amount.
|
int |
intValue()
Returns the value of this counter as an int.
|
long |
longValue()
Returns the value of this counter as a long.
|
void |
set(int count)
Sets the count to the specified value.
|
String |
toString()
Return a string representation of this counter's value.
|
int |
value()
Returns the current count value.
|
byteValue, shortValuepublic Counter()
0.public Counter(int count)
count - Initial value of counter.public int value()
public void increment()
public void increment(int n)
n - Amount by which to increase the count value.public void set(int count)
count - New value of the counter.public double doubleValue()
doubleValue in class Numberpublic float floatValue()
floatValue in class Numberpublic int intValue()
public long longValue()
Copyright © 2019 Alias-i, Inc.. All rights reserved.