Skip to content

Instantly share code, notes, and snippets.

@cronokirby
Created February 26, 2017 00:09
Show Gist options
  • Save cronokirby/ee3aafe5e56698f6f4bf7a00f0d42b3d to your computer and use it in GitHub Desktop.
Save cronokirby/ee3aafe5e56698f6f4bf7a00f0d42b3d to your computer and use it in GitHub Desktop.
package Counter;
public class Counter {
private int num;
public Counter(int num) {
this.num = num;
}
public int next() {
this.num += 1;
return this.num;
}
}
import Counter.Counter;
public class Main {
public static void main(String[] args) {
Counter counter = new Counter(0);
for (int i = 0; i < 10; i++) {
System.out.println(counter.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment