The goal that I am trying to get to is having user input the name of a movie along with the release date. To do this I have set up separate classes.
Movie cameronsMovie = new Movie("Sin City", 2005);
Movie [] movieList = new Movie [9];
movieList[0] = cameronsMovie;
for (int i = 0; i < movieList.length; i++) {
System.out.print("Please enter a movie Title: ");
String title = GetInput.readLine(); //Get movieTitle
System.out.print("Please enter the year it was released: ");
int releaseDate = GetInput.readInt(); //Get year
// creating a new ojbect
Movie userMovie = new Movie(title, releaseDate); /* calls the
constructor from Movie class
*/
movieList[i] = userMovie;
}
System.out.println(movieList.toString());
This is the code that I am using to call the other classes and the problem that I am having is with my last line of code printing out a result of [LMovie;@2a139a55
In my classes file I have this code
public String toString() {
String temp = new String();
temp = "Movie title: " + getTitle() + "\nYear of Release: " +
getYear();
return(temp);
}
to return my string. Is there something wrong with the way my toString() is set up or is there another place where I am making a mistake