这是我的课:
public class City
{
private String _cityName;
private Point _cityCenter;
private Point _centralStation;
private long _numOfResidents;
private int _noOfNeighborhoods;
private final long RESIDENTS_CONST_VALUE = 0;
private final int NEIGHBORHOODS_CONST_VALUE = 1;
}
我的构造函数之一是从其他对象(同一对象)复制:
public City(City other)
{
_cityName = other._cityName;
_cityCenter = other._cityCenter;
_centralStation = other._centralStation;
_numOfResidents = other._numOfResidents;
_noOfNeighborhoods = other._noOfNeighborhoods;
}
public Point(Point point)
{
_x = point._x;
_y = point._y;
}
此构造函数获取另一个City
对象并复制它的值。我的问题是我所做的是否可以避免混叠或者我需要做其他事情