Sample.java (566B)
1 package collections; 2 3 /* 4 // Instead of putting Packages into the samples bag, 5 // we'll create a new object Sample. This way we are 6 // not storing information that we no longer need. 7 */ 8 9 public class Sample { 10 private String name; 11 private double weight; 12 13 public Sample(String name, double weight) { 14 this.name = name; 15 this.weight = weight; 16 } 17 18 public String getName() { 19 return name; 20 } 21 22 public double getWeight() { 23 return weight; 24 } 25 26 @Override 27 public String toString() { 28 return name; 29 } 30 }