Advertisement
Aminpro

Static Variable

Dec 30th, 2013
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. public class tuna {
  2.     private String first;
  3.     private String last;
  4.     private static int members = 0;
  5.    
  6.     public tuna(String firstname, String lastname){
  7.         first = firstname;
  8.         last = lastname;
  9.         members++;
  10.         System.out.printf("Constructor for %s %s, members in the club is %d\n", first, last, members);
  11.        
  12.        
  13.     }
  14.    
  15.     public String getFirst(){
  16.         return first;
  17.        
  18.     }
  19.     public String getLast(){
  20.         return last;
  21.     }
  22.    
  23.     public static int getMembers(){
  24.         return members;
  25.     }
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement