Results 1 to 4 of 4

Thread: Interfaces

  1. #1
    blug is offline Member
    Join Date
    Oct 2010
    Posts
    26
    Rep Power
    0

    Default Interfaces

    Hey,

    Just having a bit of trouble with interfaces at the moment. Getting an error message "The type People cannot be a superinterface of White; a superinterface must be an interface".

    Java Code:
    package testing;
    
    public class White implements People{
    
    	public void setHeight(double height){
    		
    	}
    	
    	public void setBirthDate(String birth){
    		
    	}
    
    	public void setDeathDate(String death){
    	
    	}
    	
    	public void setJob(String job){
    		
    	}
    	
    }
    Java Code:
    package testing;
    
    public interface People {
    
    	public double height = 0;
    	public String birth = "0/0/0000";
    	public String death = "0/0/0000";
    	
    	public void setHeight(double height);
    	
    	public void setBirthDate(String birth);
    	
    	public void setDeathDate(String death);
    	
    }
    I always thought that an interface was just a blueprint that had to be followed if implemented by a class which I am doing with this following code?

    Any idea what could be wrong?

    Thanks!

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I am not entirely sure why your code isn't working either, however; You are correct in saying that an interface is a blueprint. All classes that implement it must have an implementation of each method in the interface. I believe that you can also not specify an accessor in an interface. Can you copy the exact error message for me?

  3. #3
    blug is offline Member
    Join Date
    Oct 2010
    Posts
    26
    Rep Power
    0

    Default

    hmm, thanks for the response. Turns out it was correct afterall, I think I must of mis-saved the interface. Kinda weird how long it took me to realize the error though lol.. Sometimes forget to save with eclipse =(

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    haha, Im glad you were able to solve it, please mark your thread solved with the thread tools.

Similar Threads

  1. Interfaces
    By blug in forum New To Java
    Replies: 1
    Last Post: 11-19-2010, 05:46 PM
  2. Interfaces
    By jon80 in forum New To Java
    Replies: 2
    Last Post: 05-03-2008, 10:57 PM
  3. interfaces..
    By sireesha in forum New To Java
    Replies: 5
    Last Post: 01-16-2008, 06:52 PM
  4. Interfaces
    By Kavana Krishnappa in forum New To Java
    Replies: 7
    Last Post: 12-11-2007, 05:28 PM
  5. Interfaces
    By imran_khan in forum New To Java
    Replies: 5
    Last Post: 07-30-2007, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •