title: How to use a variable of one class, in another in Java?
body: <p>I'm just working through a few things as practice for an exam I have coming up, but one thing I cannot get my head round, is using a variable that belongs to one class, in a different class.</p>
  
  <p>I have a Course class and a Student class. Class course stores all the different courses and what I simply want to be able to do is use the name of the course, in class Student. </p>
  
  <p>Here is my Course class:</p>
  
  <pre><code>public class Course extends Student
  {
      // instance variables - replace the example below with your own
      private Award courseAward;
      private String courseCode;
      public String courseTitle;
      private String courseLeader;
      private int courseDuration;
      private boolean courseSandwich;
  
      /**
       * Constructor for objects of class Course
       */
      public Course(String code, String title, Award award, String leader, int duration, boolean sandwich)
      {
          courseCode = code;
          courseTitle = title;
          courseAward = award;
          courseLeader = leader;
          courseDuration = duration;
          courseSandwich = sandwich;
  
      }
  
  }
  </code></pre>
  
  <p>And here is Student:</p>
  
  <pre><code>public class Student 
  {
      // instance variables - replace the example below with your own
      private int studentNumber;
      private String studentName;
      private int studentPhone;
      private String studentCourse;
  
      /**
       * Constructor for objects of class Student
       */
      public Student(int number, String name, int phone)
      {
          studentNumber = number;
          studentName = name;
          studentPhone = phone;
          studentCourse = courseTitle;
      }
  
  }
  </code></pre>
  
  <p>Am I correct in using '<strong>extends</strong>' within Course? Or is this unnecessary? </p>
  
  <p>In my constructor for Student, I am trying to assign 'courseTitle' from class Course, to the variable 'studentCourse'. But I simply cannot figure how to do this! </p>
  
  <p>Thank you in advance for your help, I look forward to hearing from you!</p>
  
  <p>Thanks! </p>