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.

3
  • Are you importing the interface? Commented Aug 25, 2012 at 12:03
  • They're probably in separate packages so you have to use import au.edu.uow.Collection.Album; in the file containing DVDAlbum. BTW, package names should be written in lowercase. Commented Aug 25, 2012 at 12:03
  • check your main class MyCollection Commented Aug 25, 2012 at 12:07

4 Answers 4

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{ } 
Sign up to request clarification or add additional context in comments.

Comments

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 { //.... } 

Comments

0

check your interface package is correctly imported.

2 Comments

if the interface is called Album.java would the import statement be Import Album.java ??
Album.java is the file name, not the interface name. You can't use dots in Java class names.
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 .

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.