title: I have an issue with a non-static method
body: <p>I have a <code>Student</code> class with the following instance variables:</p>
  
  <pre><code>int code;
  String surname, firstname, major;
  </code></pre>
  
  <p>In the <code>main</code> method (in a second class), I created <code>Student</code> objects, and I added them to a <code>Vector</code>. In the class containing the <code>main</code> method, I defined two additional methods:</p>
  
  <pre><code>public static boolean search(List list, int code)
  public static void display(List list)
  </code></pre>
  
  <p>I'd like to create another method now (<code>Student getStudent(int code)</code>) which would return a <code>Student</code> object based on the code passed as the argument.</p>
  
  <p>What I don't understand is that we're asked not to make this a static method like the other two. Furthermore, I can't manage to search for the <code>Student</code> given the code, because I don't have the list, which is created in the <code>main</code> method, as an argument!</p>
  
  <p>I need some guidance in all this.</p>
  
  <p>Here are some of my code snippets :</p>
  
  <pre><code>public class Etudiant {
  
  
  int code;
  String nom, prenom, filiere;
  
  Etudiant() { 
      this.code = 0;
      this.nom = "";
      this.prenom = "";
      this.filiere = "";  }
  
  Etudiant(int code, String nom, String prenom, String filiere){
      this.code = code;
      this.nom = nom;
      this.prenom = prenom;
      this.filiere = filiere; }
  
  public String toString(){   return code + "; " + nom + "; " + prenom + "; " + filiere +  "\n";  }   
  
  public int getCode() {  return code;    }
  
  public String getFiliere() {    return filiere; }
  
  public void setCode(int code) { this.code = code;   }
  
  public void setNom(String nom) {    this.nom = nom; }
  
  public void setPrenom(String prenom) {  this.prenom = prenom;   }
  
  public void setFiliere(String filiere) {    this.filiere = filiere; }
  }
  </code></pre>
  
  <p>And here are some snippets of the Main method </p>
  
  <pre><code>public class TestListe { 
  
  public static void main(String[] args){
  
      ArrayList &lt;Etudiant&gt; liste = new ArrayList &lt;Etudiant&gt; ();
  
  
      Etudiant e1 = new Etudiant(326, "Fouhami", "Aimen", "LOGISTIQUE");
      Etudiant e2 = new Etudiant(258, "Ait Taleb", "Souad", "INFORMATIQUE");
      Etudiant e3 = new Etudiant(789, "Elouardi", "Nadia", "ENERGIES RENOUVLABLES");
      Etudiant e4 = new Etudiant(25, "MEKKAOUI", "Oumaima", "IBPM");  
  
      liste.add(e1);
      liste.add(e2);
      liste.add(e3);
      liste.add(e4);  
  
  }
  
  // AFFICHAGE DE LA LISTE DES ETUDIANTS
  public static void affichage(List &lt;Etudiant&gt; liste){`
  
              for(int i = 0; i&lt;liste.size(); i++){
                  System.out.print(liste.get(i));
              }
  
          }
  // RECHERCHE D'UN ETUDIANT PAR LE CODE
  public static boolean recherche(List liste, int code){
              int i = 0;
              Etudiant e;
  
              do{
                  e = (Etudiant) liste.get(i);
                  i++;
  
              }   while(i&lt;liste.size() &amp;&amp; e.getCode() != code);
  
  
              if(e.getCode() == code) return true;
  
              else return false;  
          }
  </code></pre>