I need to know how to set a variable to this value in Java
<hr>

<pre><code>       **NEVERMIND, I CHEATED**
</code></pre>

<hr>

<pre><code>Movie[] movies = new Movie[8];
movies[0] = new Movie("The Godfather", 1972);
</code></pre>

<p>Say I have a bunch of movies variables, how could I set a variable (call it year or something) to the year in the movies[] variable?</p>

<p>(im in a programming class and my assignment was to debug a file, my only error left is that i need to make the year variable set to the year in movies[])</p>

<p>Heres my complete code:</p>

<pre><code>import javax.swing.*;
public class DebugNine2
{
public static void main(String[] args)
   {
  Movie[] movies = new Movie[8];
  Movie[] year;
  int i;
  String message, entry;
  movies[0] = new Movie("The Godfather", 1972);
  movies[1] = new Movie("The Good, the Bad, and the Ugly", 1966);
  movies[2] = new Movie("Pulp Fiction", 1994);
  movies[3] = new Movie("Shindler's List", 1993);
  movies[4] = new Movie("Casablanca", 1942);
  movies[5] = new Movie("Wizard of Oz", 1939);
  movies[6] = new Movie("Citizen Kane", 1941);
  movies[7] = new Movie("Some Like It Hot", 1959);
  entry = JOptionPane.showInputDialog(null,
    "Sort Movies by\n(N)ame, or (Y)ear");
  if(entry.equals("N"))
  {
     nameSort(movies);
     message = "Sorted by Name\n";
  }
  else
  {
      year=movies;
      yearSort(year);
      message = "Sorted by Year\n";
  }   
  display(movies, message);
  //System.out.println(movies+"\n"+message);
}
public static void nameSort(Movie[] array)
{
  int a, b;
  int highSub = array.length - 1;
  for(a = 0; a &lt; highSub; ++a)
  {
     for(b = 0; b &lt; highSub; ++b)
 {
         String first = array[b].getName();
         String second = array[b + 1].getName();
         if(first.compareTo(second) &gt; 0)
     {

        Movie temp = array[b];
        array[b] = array[b + 1];
        array[b + 1] = temp;
     }
  }
   }
}
public static void yearSort(Movie[] array)
{
    int a, b;
    Movie temp;
    int highSub = array.length;
    for (a = 0; a &lt; highSub; ++a)
    {
       for (b = 0; b &lt; highSub; ++b)
       if (array[b].getYear() &gt; array[b + 1].getYear())
       {
          temp = array[b];
          array[b] = array[b + 1];
          array[b + 1] = temp;
       }
    }
 }
 public static void display(Movie[] s,  String msg)
 {
    for (int i = 0; i &lt; 8; i++)
       msg = msg + s[i].getName() + ", " + s[i].getYear() + "\n";
    JOptionPane.showMessageDialog(null, msg);
 }
}
</code></pre>

<p>additionally, there is a file called Movie.java which contains the code</p>

<pre><code>public class Movie
{
private String name;
private int year;
Movie(String s, int y)
{
  name = s;
  year = y;
}
public String getName()
{ 
  return name;
}
public int getYear()
{
  return year;
}
}
</code></pre>
