Students, please be sure to log in. This site does not use cookies and does not track/store work submitted when not signed in.
Unit 6 Problems
Java Reference Sheet
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);
}
}