Java

Posts tagged with "Java."
  • 10

    MAR
    2006

    Java a Bit on the Wordy Side

    I was helping a friend of mine with a Java problem yesterday and couldn't help but notice this totally normal (for Java) file in his project:

    import java.io.Serializable;
    
    public class Contact implements Serializable
    {
       private String firstName;
       private String lastName;
       private String email;
       private String phone;
    
       public Contact()
       {
           this("", "", "", ""); // call four-argument constructor
       } // end no-argument Contact constructor
    
       // initialize a record
       public Contact(String first, String last, String eml, String phn)
       {
           setFirstName(first);
           setLastName(last);
           setEmail(eml);
           setPhone(phn);
       } // end four-argument Contact constructor
    
       // set first name
       public void setFirstName(String first)
       {
          firstName = first;
       } // end method setFirstName
    
       // get first name
       public String getFirstName()
       {
          return firstName;
       } // end method getFirstName
    
       // set last name
       public void setLastName(String last)
       {
          lastName = last;
       } // end method setLastName
    
       // get last name
       public String getLastName()
       {
          return lastName;
       } // end method getLastName
    
       // set email address
       public void setEmail(String eml)
       {
          email = eml;
       } // end method setEmail
    
       // get email address
       public String getEmail()
       {
          return email;
       } // end method getEmail
    
       // set phone number
       public void setPhone(String phn)
       {
          phone = phn;
       } // end method setPhone
    
       // get phone
       public String getPhone()
       {
          return phone;
       } // end method getPhone
    } // end class Contacts
    

    Read moreā€¦