title: Calling a method from other class, inside other method
body: <p>I couldn't find a solution anywhere, so here it is:</p>
  
  <p>A school project says that to use <code>isEqual(Student)</code> method I must use the <code>hasSameName(Person)</code> inside it.
  I have created two classes, <code>Student</code> and <code>Person</code> where <code>boolean hasSameName(Person persons[])</code> compare the names inside the array and returns <code>true</code> if same name found and <code>false</code> if there's no same person.</p>
  
  <pre><code>public class Person{
      private String name,surname,address,email,phoneNumber;
  
      public Person(String name,String surname,String address,String email,String phoneNumber) {
  
          this.name = name;
          this.surname = surname;
          this.address = address;
          this.email = email;
          this.phoneNumber = phoneNumber;
  
      }
  ...
  ...
  ...
  
  public boolean hasSameName(Person persons[]) {
  
          boolean flag = false;
  
          for(int i = 0; i&lt;persons.length; i++) {
              for (int j = i+1; j&lt; persons.length; j++) {
                  if((persons[i].getName() == persons[j].getName() &amp;&amp; (i!=j))){
                      flag = true;
                  }
              }
          }
  
          if(flag == true)
              return true;
          else
              return false;
  
      }
  </code></pre>
  
  <p>The project says that <code>boolean isEqual(Student name, Student id)</code> should compare the name and the id values but <code>hasSameName(Person)</code> method must be used.</p>
  
  <p>Here is the <code>Student</code> class:</p>
  
  <pre><code>public class Student extends Person {
  
      private int studentID,semester;
  
      public Student(String name,String surname,String address,String email,String phoneNumber,int studentID,int semester) {
  
          super(name,surname,address,email,phoneNumber);
          this.studentID = studentID;
          this.semester = semester;
  
      }
  .
  .
  .
  .
  
      public boolean isEqual(Student name,Student id) {
           //****************i am stuck here. I don't know how to make it work.*******************
      }
  
  </code></pre>
  
  <p>Any help will be appreciated.</p>