Methods without any return value in Java
Forums:
class Counter {
public int count;
public void incBy(int value) {
count += value;
}
public void incBy(int value, int amount) {
count += value * amount;
}
}
Counter counter = new Counter();
counter.incBy(1);
//counter.Count is 1
counter.incBy(2, 5);
//counter.Count is 11
- Log in to post comments