Created
February 26, 2017 00:09
-
-
Save cronokirby/ee3aafe5e56698f6f4bf7a00f0d42b3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Counter; | |
public class Counter { | |
private int num; | |
public Counter(int num) { | |
this.num = num; | |
} | |
public int next() { | |
this.num += 1; | |
return this.num; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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