I am trying to make use a class I made, but when I call the class is doesn’t work and I am kind of lost.
The error is coming at the class call and initialization of tally at the bottom of the program.
package counter;
public class Counter {
private int value;
public Counter(int intialValue){
value = intialValue;
}
private void count() {
value = value + 1;
}
private void reset(){
value = 0;
}
public int getValue(){
return value;
}
Counter tally = new Counter();
tally.count();
}
All Java statements must be put into a method of some kind.
Currently your last two lines are not in a method.
Try something like this: