I am creating a Video class, then creating objects to place into an array. Then I want to print the contents of the array:
public class Video {
String videoTitle;
int videoRating;
public Video (String pVideoTitle, int pVideoRating){
videoTitle = pVideoTitle;
videoRating = pVideoRating;
}
}
public class VideoStore {
public VideoStore(){
run();
}
private void run(){
buildArray();
printArray();
}
private void buildArray(){
Video[] inventory = new Video[5];
inventory[0] = new Video ("Meet the Fockers", 5);
inventory[1] = new Video ("Blade" , 3);
inventory[2] = new Video ("Spiderman 2 " , 4);
inventory[3] = new Video ("Finding Nemo" , 3);
inventory[4] = new Video ("Star Wars II" , 1);
}
private void printArray(inventory[]){
for (int i = 0; i < inventory.length; i++){
System.out.println(inventory[i]);
}
}
public static void main(String[] args) {
new VideoStore();
}
}
I am getting an error in the printArray method. It does not like how I reference the inventory array.