Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]){
- Duck d;
- d = new Duck(4);
- d = new Duck(6);
- d = new Duck(8);
- System.out.println(d.getCount());
- }
- }
- class Duck{
- private int size;
- private static int duckCount= 0;
- public Duck(int size){
- this.size = size;
- duckCount++;
- }
- public int getCount(){
- return duckCount;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement