makeChicken
Objective(s): Practice creating an array of objects and working with a Java class.
Given the Chicken
class below, create 10 Chicken
objects stored in an array.
Takeaway:
When dealing with arrays of objects. You need to individually instantiate the objects. In the declaration and instantiation of the object array, the array contains references to the objects. If the objects do not exist, then you will have null values! A null
value in programming is an uninitialized, undefined, empty, or meaningless value.
public class Chicken{
private double weight;
public Chicken(){
weight = (int)(Math.random()*101);
}
}
Type your solution
Skills Practiced:
3.C
3.A
3.D
4.A
4.B
Saved
Saved