Java Developer Db4o Guide: Arrays and collections

Source: Internet
Author: User

Dealing with diversity relationships

A comfortable family life can lead to one or more "little ones" coming to this family. However, before adding a child to the family, make sure that the person has a real place to live. Give them a place to work, or a good summer vacation home. An address type should be able to solve all of these three places.

Listing 1. Add an address type to the person class

Package Com.tedneward.model
public class address
{
Public address ()
{
}
Public Address ( String Street, String city, string state, String Zip)
{
This.street = Street; this.city = city;
This.state = s Tate This.zip = Zip;
}
Public String toString ()
{
return ' [Address: +
' street= ' + street +] "+
" city= "+ City +" "+
" state= "+ state +" "+
" zip= "+ Zip +"] ";
}
Public int hashcode ()
{
return Street.hashcode () & City.hashcode ()
State.hashcode () & Zip.hashcode ();
}
Public boolean equals (Object obj)
{
if (obj = =)
Return this,
if (obj instanceof address) {
Address RHS = [address] obj;
return (This.street.equals (rhs.street) &&
This.city.equals ( rhs.city) &&
This.state.equals (rhs.state) &&
This.zip.equals (Rhs.zip));
}
Else
return false;
}
Public String Getstreet () {return this.street;
public void Setstreet (String value) {this.street = value;}
Public String getcity () {return this.city;}
public void setcity (String value) {this.city = value;}
Public String getState () {return this.state;}
public void SetState (String value) {this.state = value;}
Public String Getzip () {return this.zip;}
public void Setzip (String value) {this.zip = value;}
Private String Street;
Private String City;
Private String State;
Private String zip;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.