title: How do you use methods from sub classes in the main class in Java?
body: <p>I am working on an assignment and I can not figure out what to do. I have three different Java classes. And I am trying to use the methods in one class to do something in a different class. I am making a very primitive playlist program. I have to check to see if the playlist is full, if its not i have to ask the title and artist. Then I have to call my method using the title and artist as parameters. I was wondering if anyone could point me in the right direction as to what I had to do to call the method? I still don't completely understand loops either but i know that I have to use a for loop in order to do this. Thankyou for your time. </p>
  
  <p>Here is my code:</p>
  
  <p>Main Class</p>
  
  <pre><code>import java.util.Scanner;
  public class Main {
  
  public static void main(String[] args) {
     PlayList p = new PlayList (5);
     Scanner sc = new Scanner(System.in);
     String command;
     String title;
     String artist;
  
  
  
    System.out.println("Enter a to add, r to remove, d to display,or q to 
    quit:");
    command = sc.nextLine();
    while (!command.equals("q")) {
    // Interpret command
    if (command.equals("a")) {
     //add song
   for (int i = 0; i &lt;= PlayList.isFull(title, artist);i++) {
       if(songs[i])== null {
       songs[i] = filled;
    }
  
  
    }
  
    } else if (command.equals("r")) {
    // Remove a song
    System.out.print("Title: ");
    title = sc.nextLine();
    p.remove(title);
    } else if (command.equals("d")) {
    // Fill this in
    }
    // Get the next command
    System.out.println("Enter a to add, r to remove, d to display, or q to 
    quit:");
    command = sc.nextLine();
     }
    System.out.println("Program Ended");
  
     }
     }
  </code></pre>
  
  <p>PlayList Class</p>
  
  <pre><code>public class PlayList {
  private Song [] songs;
  private int filled;
  
  public PlayList (int size){
      songs = new Song[size];
  }
  public boolean isFull() {
      return (filled &gt;= songs.length);
  }
  public void add(String t, String a) {
      for (int i = 0; i &lt; songs.length; i++){
          if (songs[i] == null){
              songs[i] = new Song(t,a);
              filled++;
          }
      }      
  }
  public void display() {
      for (int i = 0; i &lt; songs.length; i++){
          if (songs[i] != null) {
              System.out.println(songs[i]);
          }
      }
  }
  public void remove(String t) {
      //return t?
      for (int i = 0; i &lt; songs.length; i--){
          if (songs[i] == null){
              songs[i] = null;
              break;
  }
  }
  }
  }
  </code></pre>
  
  <p>Song Class</p>
  
  <pre><code>public class Song {
  String title;
  String artist; 
  
  public Song (String t, String a) {
  title = t;
  artist = a; 
  }
  public String toString() {
  return "Title: " + title + " " + "Artist: " + artist;
  
  }
  
  }
  </code></pre>