public class City { private String name; private String stateAbbrev; private String zip;
public String getName() { return this.name; } public String getStateAbbrev() { return this.stateAbbrev; } public String getZip() { return this.zip; }
public class City { private String name; private String stateAbbrev; private String zip;
public void setName(String nm) { this.name = nm; } public void setStateAbbrev(String abbr) { this.stateAbbrev = abbr; } public void setZip(String z) { this.zip = z; }
public City(String name, String stateAbbrev, String zip) { this.name = name; this.stateAbbrev = stateAbbrev; this.zip = zip; } //When you want a copy and want to preserve the original public City(City source) { this(source.getName(), source.getStateAbbrev(), source.getZip()); } //end constructors
City copy = new City(city1);
List<Integer> original = new ArrayList<>(); original.add(5); List<Integer> copy = new ArrayList<>(original);