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.
4 Answers 4
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{ }
Comments
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 {
//....
}
Comments
check your interface package is correctly imported.
2 Comments
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 .
import au.edu.uow.Collection.Album;in the file containingDVDAlbum. BTW, package names should be written in lowercase.