2

this is my attempt at implementing an interface.

im getting the following error

javac MyCollection.java
./au/edu/uow/Collection/DVDAlbum.java:6: cannot find symbol
symbol: class Album
public class DVDAlbum implements Album{

this is the super class

package au.edu.uow.Collection;


public interface Album {

    String getMediaType();

    String getTitle();

    String getGenre();

}

And this is the sub class

public class DVDAlbum implements Album{

    private String Title;
    private String Genre;
    private String Director;
    private String Plot;
    private String MediaType;

    public DVDAlbum(String TempTitle, String TempGenre, String TempDirector, String TempPlot){
        Title = TempTitle;
        Genre = TempGenre;
        Director = TempDirector;
        Plot = TempPlot;
    }
    String getMediaType(){
        return MediaType;
    }
    String getTitle(){
        return Title;
    }
    String getGenre(){
        return Genre;
    }
}

http://www.javabeginner.com/learn-java/java-abstract-class-and-interface This was the reference i used but its not working for me.

Daniel Del Core
  • 3,071
  • 13
  • 38
  • 52

4 Answers4

2

If you aren't in the same package where the interface is declared, you need to import it:

import au.edu.uow.Collection.Album;

Or use the complete qualified name:

public class DVDAlbum implements au.edu.uow.Collection.Album{ }
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
1

Add following

import au.edu.uow.Collection.Album;

public class DVDAlbum implements Album{
    //....
}

and

import au.edu.uow.Collection.DVDAlbum;
import au.edu.uow.Collection.Album;

public class MyCollection {
    //....
}
Bharat Sinha
  • 13,973
  • 6
  • 39
  • 63
0

check your interface package is correctly imported.

Mohammod Hossain
  • 4,134
  • 2
  • 26
  • 37
0

The error message

./au/edu/uow/Collection/DVDAlbum.java:6: cannot find symbol

means, that DVDAlbum and Album are intended to be in the same package and therefore no import is necessary.

BUT: The DVDAlbum is NOT in the right package because the package line is missing. So just copy the package line from Album into DVDAlbum .

A.H.
  • 63,967
  • 15
  • 92
  • 126